POV-Ray : Newsgroups : povray.general : The Language of POV-Ray : Re: The Language of POV-Ray Server Time
10 Aug 2024 15:21:29 EDT (-0400)
  Re: The Language of POV-Ray  
From: Axel Baune
Date: 10 Mar 2000 06:20:30
Message: <38C8DAB2.3BE14CC3@neuro.informatik.uni-ulm.de>
Hello,

PoD wrote:
> 
> Axel Baune wrote:
> >
> >[Snip]
> >Another problem will be the
> > 'dirty' programming for people without programming-knowledge. The
> > example given by PoD is one of them:
> 
> dirty programming?

Sorry, I didn't wanted to say that the given example incorporates dirty
programming. What I've meant to say was, that from the given example
could dirty programming easily derived (see my desciption of problems
and the following)   

> > No I think not that this would make life easier for all. Problem one:
> > what will be the value of the variables outside the for-loop?
> 
> The same as it would be using a while loop?

No, I don't think so. In most programming languages the state of the
variables used in a for-loop are undefined outside the loop, but most
programmers ignores this and use the mostly undocomented feature, that
after the for-loop the variable has the value of the variable in the
last loop incremented by the specified step. Whereas after a while loop
the variable has the value obtained by the last user operation on the
variable. The problem derives, because in a for loop the variable
belongs sytactically to the for command. From the viewpoint of a
computer scientist  (I'm one) the variable in a for-loop should _never_
be changeable by a user and should have only one variable, but most
compiler of programming languages ignores this, beause it is to
complicated to prove this. Threrfore while-constructs show a more well
defined behaviour and should always be used.

> >Problem
> > two: What if you want to increment the variable in non deterministic
> > steps, e.g. different steps width in each loop or you didn't want to
> > increment in each loop. Than you will need the old while-construct, and
> > why blowing up Pov-Script with higly specialised commands if you already
> > have flexibler and more general commends for them? As a more skilled
> > programmer you can always write macros for specialised problems. 

> Then use a while loop and nothing is lost, except that you've made your
> script hard to read.  There's probably an easier way to do it using
> for()

No, you couldn't do everything with a for-loop what you could do with a
while-loop. The while-loop is far more flexible, beacuse the for-loop is
a special case of the while-loop for cases where _one_ variable is
looped through a range of values with a constant step width. 

> >Problem
> > three: What if somebody changes the variable explicitly inside the
> > loop-body. I think these problems complicates the life of PoV-people
> > without programming-knowledge, especially if some of these persons want
> > to understand code from other people with more skilled
> > programming-knowledge (especially if those people used 'dirty' and
> > mostly undocumented programming constructs).
> 
> See answer to 2

See answer to 1

Yours Axel Baune


Post a reply to this message

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