|
|
Warp <war### [at] tagpovrayorg> wrote:
> Trevor G Quayle <Tin### [at] hotmailcom> wrote:
> > One further item on the potential creation of #for loops: Would they be best
> > end-bracketted with the general #end statement (as #while, #if, #switch and
> > #macro all use)? Or would it be more appropriate to add a "#next" statement or
> > even "#next n" statement instead? #end would make it more consistent with
> > current programming practice, but #next would make the #for loop construct more
> > visible and identifiable.
>
> I don't support the idea of adding new keywords just to serve as comments.
> If you want to comment your code, use comments. I personally use this style
> quite a lot:
>
> #while(a < b)
> some stuff here
>
> #while(c < d)
> some other stuff here
>
> #if(something)
> more stuff here
> #end // #if(something)
>
> additional stuff
>
> #end // #while(c < d)
> #end // #while(a < b)
>
> (In fact, I use this style with large blocks when programming in C++ as
> well.)
>
> --
> - Warp
I wasn't necessarily arguing for the addition of the keywords, just commenting
on whether a #for loop should be consistent with the other constructs and end
with #end. If it was felt that they should have their own #next keyword, then
the extension of that argument would be that all the other constructs should as
well.
I will admit that having a bunch of nested #end statements can become confusing
figuring out which belongs to any of the constructs present without good
commenting and/or scoping. However, adding the commenting does require extra
typing and lessens the conciseness of the construct which is one of the
arguments in favour of adding #for.
One thing you can't do at present would be something along the lines of:
#declare i=0;
#while (i<5)
...
#if (something happens that makes me want to terminate the loop early)
#declare i=-1;
#end
#else
#declare i=i+1;
#end
#end
as the #end statements get confused. Granted this is not good programming
protocol and is achievable by other methods, it is merely a demonstration of a
conceivable issue. Construct-specific end statements could allow for this
(however, leaving #end for backwards compatibility would preclude allowing this
anyways).
All in all, I would support the continued usage of #end for all constructs as
well as for a new #for construct.
-tgq
Post a reply to this message
|
|