POV-Ray : Newsgroups : povray.general : Question 'bout indentation (no flamewar) Server Time
15 Nov 2024 01:15:43 EST (-0500)
  Question 'bout indentation (no flamewar) (Message 1 to 10 of 12)  
Goto Latest 10 Messages Next 2 Messages >>>
From: Roland Mas
Subject: Question 'bout indentation (no flamewar)
Date: 29 Mar 1999 12:49:33
Message: <m3k8w0chjo.fsf@clodomir.rezel.enst.fr>
Hi all.

I have a question about indentation.  I fear it might degenerate
into another flamewar, but heh, such is life.  On the other hand, it
might bring some arguments to Ken Tyler.

  Suppose you have the following lines:

#if (A > 0)
union {
#endif
sphere { ... }
#if (A > 0)
sphere { ... }
}
#endif

  How would you indent?

  The point is: there are two different hierarchies that have nothing
to do with each other /a priori/.  You cannot mix them, 'cause you end
up with incoherences.

  The other point is: do you indent the first sphere?  At write time,
you don't know whether the union will exist (if you did, the test
would be useless).  So, do you indent the sphere as inside the union,
or do you leave it unindented?

  Might be of some interest to discuss, although I'm afraid the issue
is insoluble.

Roland.
-- 
Roland Mas

Sauvez les castors, plantez des arbres.


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Question 'bout indentation (no flamewar)
Date: 29 Mar 1999 13:08:05
Message: <36ffc185.0@news.povray.org>
In article <m3k### [at] clodomirrezelenstfr> , 
rol### [at] casimirrezelenstfr (Roland Mas) wrote:

>   Hi all.
>
> I have a question about indentation.  I fear it might degenerate
> into another flamewar, but heh, such is life.  On the other hand, it
> might bring some arguments to Ken Tyler.
>
>   Suppose you have the following lines:
>
> #if (A > 0)
> union {
> #endif
> sphere { ... }
> #if (A > 0)
> sphere { ... }
> }
> #endif
>
>   How would you indent?


                        #if (A > 0)
union
{
                        #endif
    sphere { ... }
                        #if (A > 0)
    sphere { ... }
}
                        #endif



OR BETTER


#declare mySphere1 = sphere { ... }
#declare mySphere2 = sphere { ... }

#if (A > 0)
union
{
    sphere { mySphere1 }
    sphere { mySphere2 }
}
#else
sphere { mySphere1 }
#endif


    Thorsten


Post a reply to this message

From: Roland Mas
Subject: Re: Question 'bout indentation (no flamewar)
Date: 29 Mar 1999 13:22:14
Message: <m3emm8cg15.fsf@clodomir.rezel.enst.fr>
"Thorsten Froehlich" <fro### [at] charliecnsiitedu> writes:

>                         #if (A > 0)
> union
> {
>                         #endif
>     sphere { ... }
>                         #if (A > 0)
>     sphere { ... }
> }
>                         #endif

Nah.  Doesn't work.  The first sphere is indented and should only be
so if A > 0.

> OR BETTER
> 
> 
> #declare mySphere1 = sphere { ... }
> #declare mySphere2 = sphere { ... }
> 
> #if (A > 0)
> union
> {
>     sphere { mySphere1 }
>     sphere { mySphere2 }
> }
> #else
> sphere { mySphere1 }
> #endif

  Yes.  Works better, for sure.  I had thought of it, but it only
works for small scenes.  If you have plenty depending on A, it becomes
really hard to read.
-- 
Roland Mas

A man walks into a bar.  Bang.


Post a reply to this message

From: Nieminen Mika
Subject: Re: Question 'bout indentation (no flamewar)
Date: 29 Mar 1999 13:33:33
Message: <36ffc77d.0@news.povray.org>
Roland Mas <rol### [at] casimirrezelenstfr> wrote:
:   Suppose you have the following lines:

: #if (A > 0)
: union {
: #endif
: sphere { ... }
: #if (A > 0)
: sphere { ... }
: }
: #endif

:   How would you indent?

  In this case the #if statement doesn't stand for conditional code
execution (like 'if' in C) but for conditional parsing instead (like '#if'
in C) (it's often a bad thing that povray doesn't distinguish between these
two things).
  Conditional parsing (or compiling) is always a tricky thing. It makes
the code hard to understand almost always. It's also very hard to indent.
  In this case I usually do something like this:

#if(A>0)
  union {
#end

    sphere { ... }

#if(A>0)
    sphere { ... }
  }
#end

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Roland Mas
Subject: Re: Question 'bout indentation (no flamewar)
Date: 29 Mar 1999 13:45:51
Message: <m3pv5sjfs1.fsf@clodomir.rezel.enst.fr>
Nieminen Mika <war### [at] cctutfi> writes:

>   Conditional parsing (or compiling) is always a tricky thing. It makes
> the code hard to understand almost always. It's also very hard to
> indent.

Sure.  But in the case of POV-Ray, which behaves like an interpreted
language, the difference between conditional parsing and conditional
execution is non-existent.  To my mind.
-- 
Roland Mas

It would be hard to be deader without special training.
  -- Theatre of Cruelty (Terry Pratchett)


Post a reply to this message

From: Bob Hughes
Subject: Re: Question 'bout indentation (no flamewar)
Date: 29 Mar 1999 20:25:22
Message: <370027F3.1CC2D10B@aol.com>
I'll bite, even though I had such a hard time just now getting through
the "other" latest round of indentation threading.

#if (A > 0)
 union {
#endif
  sphere { ... }
#if (A > 0)
  sphere { ... }
 }
#endif

Sloppy indenting maybe but you asked. Guess I better explain my casual
indentation method just the same.
To me the #if's and corresponding #endif's are the priority in this and
aren't embedded in one another so are left-most, no need to indent one
or the other set. The union is second priority to me and inset once,
closing brace aligned with the union keyword. The spheres (final
priority) are equal objects and indented inward of the union; not
affecting one or the other such as in a difference, intersection, or
merge, so are lined up along the vertical column.
That too simplistic? Well now you know about my style, simple even if
not exactly understandable on down the pike.


Roland Mas wrote:
> 
>   Hi all.
> 
> I have a question about indentation.  I fear it might degenerate
> into another flamewar, but heh, such is life.  On the other hand, it
> might bring some arguments to Ken Tyler.
> 
>   Suppose you have the following lines:
> 
> #if (A > 0)
> union {
> #endif
> sphere { ... }
> #if (A > 0)
> sphere { ... }
> }
> #endif
> 
>   How would you indent?
> 
>   The point is: there are two different hierarchies that have nothing
> to do with each other /a priori/.  You cannot mix them, 'cause you end
> up with incoherences.
> 
>   The other point is: do you indent the first sphere?  At write time,
> you don't know whether the union will exist (if you did, the test
> would be useless).  So, do you indent the sphere as inside the union,
> or do you leave it unindented?
> 
>   Might be of some interest to discuss, although I'm afraid the issue
> is insoluble.
> 
> Roland.
> --
> Roland Mas
> 
> Sauvez les castors, plantez des arbres.

-- 
 omniVERSE: beyond the universe
  http://members.aol.com/inversez/homepage.htm
 mailto:inv### [at] aolcom?Subject=PoV-News


Post a reply to this message

From: Tom Melly
Subject: Re: Question 'bout indentation (no flamewar)
Date: 30 Mar 1999 03:34:26
Message: <37008c92.0@news.povray.org>
k.i.s.s. - i don't think using #if in the way you did is a good habit - many
languages would probably refuse to compile. Besides, standardised code is
easier to read, indent and debug.

Even in pov, i would have thought you might be vulnerable to future release
changes, since the usage wouldn't necesserely be preserved (I haven't tested
your code, but I assume it works in current versions).

I would suggest one of the following two versions (untested, so i apol. for
any mistakes):

#if (A > 0)
    union {
        sphere { ... }
        sphere { ... }
    }
#else
    sphere { ... }
#endif

Or:

union {
    sphere { ... }
     #if (A > 0)
         sphere { ... }
     #endif
}



your version:

> #if (A > 0)
> union {
> #endif
> sphere { ... }
> #if (A > 0)
> sphere { ... }
> }
> #endif


Post a reply to this message

From: Nieminen Mika
Subject: Re: Question 'bout indentation (no flamewar)
Date: 30 Mar 1999 11:45:29
Message: <3700ffa9.0@news.povray.org>
Tom Melly <tom### [at] aolcom> wrote:
: #if (A > 0)
:     union {
:         sphere { ... }
:         sphere { ... }
:     }
: #else
:     sphere { ... }
: #endif

  This is not good coding since you are repeating code unnecesarily.
  You should declare the repeated sphere code as an identifier and use that
identifier instead.

: union {
:     sphere { ... }
:      #if (A > 0)
:          sphere { ... }
:      #endif
: }

  This is not good coding either, since you get a warning when A<=0.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Johannes Hubert
Subject: Re: Question 'bout indentation (no flamewar)
Date: 30 Mar 1999 12:44:20
Message: <37010d74.0@news.povray.org>
Nieminen Mika wrote in message <3700ffa9.0@news.povray.org>...

>  This is not good coding
[snip]
>  This is not good coding either, since you get a warning when A<=0.

I would agree with your first assessment, since code duplication leads to
problems once you start to change code and forget to do it in all places
where you duplicated it.

However, I would disagree with your second opinion:
Getting warnings is not a bad thing in general, because they are just that:
"Warnings". They mean "Hey something here *might* be wrong, you're sure you
wanna do this?" and you always have the choice (as in the given situation)
to say "Yes, damn sure! ;-)"

So long,
Johannes.


Post a reply to this message

From: Nieminen Mika
Subject: Re: Question 'bout indentation (no flamewar)
Date: 31 Mar 1999 02:07:59
Message: <3701c9cf.0@news.povray.org>
Johannes Hubert <jhu### [at] algonetse> wrote:
: However, I would disagree with your second opinion:
: Getting warnings is not a bad thing in general, because they are just that:
: "Warnings". They mean "Hey something here *might* be wrong, you're sure you
: wanna do this?" and you always have the choice (as in the given situation)
: to say "Yes, damn sure! ;-)"

  Perhaps in this case. However in C (and C++) a warning is almost always
advisable and should be considered as an error message (this is what they
have taught me and this is what I have seen by experience).

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

Goto Latest 10 Messages Next 2 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.