POV-Ray : Newsgroups : povray.general : The Language of POV-Ray : Re: The Language of POV-Ray Server Time
10 Aug 2024 23:23:43 EDT (-0400)
  Re: The Language of POV-Ray  
From: Johannes Hubert
Date: 11 Mar 2000 04:53:00
Message: <38ca177c$1@news.povray.org>
"Axel Baune" <aba### [at] neuroinformatikuni-ulmde> wrote in message
news:38C8DAB2.3BE14CC3@neuro.informatik.uni-ulm.de...
>
> 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.

Not really correct either. You are probably thinking of C++, where the
ISO/ANSI standard says that a variable declared (and initialized) inside
of the for-statement is defined only in the statement and the block that
belongs to it. A fact that is still ignored by most compilers (the
standard is still kind of fresh).

But:

This is true only for for-loops like this one:

    for (int i = start; i != end; i++) {
    }

If you rewrite the loop like this:

    int i;
    for (i = start; i != end; i++) {
    }

then there is no ambiguity about if or if not "i" is defined after the
loop and which value it has. It *is* defined and *has* the value
assigned to it during the last executed operation that modified it.

Johannes.


Post a reply to this message

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