POV-Ray : Newsgroups : povray.advanced-users : union of unions Server Time
29 Jul 2024 18:19:46 EDT (-0400)
  union of unions (Message 41 to 43 of 43)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Warp
Subject: Re: (union of unions); indentation style
Date: 14 Sep 2002 12:11:43
Message: <3d835fbf@news.povray.org>

>   (1) look at the "}";
>   (2) move your focus to the white space preceding it;
>   (3) move your focus up over WHITE space until you see
>       BLACK;
>   (4) you are looking at the keyword!

  This is not as easy with several nested code blocks. If there's a lot if
white space at *both* sides of the column you are looking at, it can be more
difficult to see which of the lines is at the same indentation level as the }.

> /* typical Pascal indentation */
> if Condition then             begin
>     DoThis
>     DoThat                    end
>   else                        begin
>     DoOther
>     DoMore                    end;

> Perfectly aligned AND readable, isn't it? :))

  Nope. The indentation is not logical. Some blocks are indented with 2 spaces
and others with 4 spaces. There's no consistency. The 'else' is not inside
of the 'if' block, but is at the same level, thus indenting it more than the
'if' is ilogical.
  With a simple example there's no confusion, but make 4 nested if-then-elses
and it begins to be quite a lot more confusing.

  Indentation should be logical, consistent and easy to understand.
Indenting one thing in one way and another thing in another way, and
specially indenting in a way that several nested blocks make the code
confusing is not good.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Fidel viegas
Subject: Re: (union of unions); indentation style
Date: 15 Sep 2002 09:19:14
Message: <B9AA4684.4AFE%fidel.viegas@artrecognition.co.uk>
I am sorry, but I have to disagree with you. The other two styles are much
more readable. But then again, if it makes you happy and you can read it,
then good for you. But, I would have to take a while to understand it,
specially if there is a lot of nested code. I can get used to it, but it
isn't as readable as the other ones.
That's just my opinion on the subject. I do respect everyone's style, but
there are some styles more readable than others.

All the best

Fidel.
 

in article 3D834E68.BA3FFD7F@computermuseum.fh-kiel.de, Frank 'Sputnik'


> Hi,
> 
> I can't decide if I should pour cold water over you all or
> throw some dynamite into the flames, so I'll try both --
> here comes the third style:
> 
> // typical indentation example
> keyword { required_parameters
> optional_parameters
> optional_parameters
> }
>
> This is completely logical, because
> - *everything* belonging to the keyword is indented,
> including, of course, the "}"
> - no (almost) empty line separates the keyword from
> its parameters
> - it's easy to find the keyword belonging to a "}":
> (1) look at the "}";
> (2) move your focus to the white space preceding it;
> (3) move your focus up over WHITE space until you see
> BLACK;
> (4) you are looking at the keyword!
> 
> It isn't a dogma to me, just a rule of thumb to improve
> readability of _my_ code. To check braces, I don't (ab)use
> my eyes; 'Match Braces' will do that faster and more reliable
> than I ever could. I don't care much about the braces -- they
> are for the _computer_, not for me; I don't need them.
> Indentation is for humans, that's all _I_ need.
> For me the most powerful formatting means is white brace-
> free space (horizontally and vertically; and comments, of
> course).
> 
> The same style can be used for other 'bracing pairs' like
> #case/#break, #if/#else/#end:
> 
> // typical indentation example
> #macro MyObject ( Para )
> DoThis
> DoThat
> #end//macro MyObject
> 
> Those who want aligned braces (and 'bracing pairs') might
> use my Pascal-Style:
> 
> /* typical Pascal indentation */
> if Condition then             begin
> DoThis
> DoThat                    end
> else                        begin
> DoOther
> DoMore                    end;
> 
> Perfectly aligned AND readable, isn't it? :))
> 
> For a real POV-Ray example see my post in p.g on 3rd sept.
> concerning with 'Intersection with quartic: bug?'.
> 
> Oh, I don't want to convince anybody that my style is the
> best -- my intention is to show the friendly coexistence
> of 3 (or more) 'truths'.
> 
> Make POV, not war!
> 
> Sputnik
> 
> 
> e-mail: fr (at) computermuseum (dot) fh-kiel (dot) de


Post a reply to this message

From: Shay
Subject: Re: (union of unions); indentation style
Date: 16 Sep 2002 11:02:56
Message: <3d85f2a0$1@news.povray.org>

news:3D834E68.BA3FFD7F@computermuseum.fh-kiel.de...

It's because of these types of issues that I comment *every* line. That way,
when I think that breaking my style makes the code more readable/logical, I
can still see exactly what I was doing when I go back.

-Shay


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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