POV-Ray : Newsgroups : povray.pov4.discussion.general : I want to be rid of my stupid mistakes : Re: I want to be rid of my stupid mistakes Server Time
1 May 2024 01:19:37 EDT (-0400)
  Re: I want to be rid of my stupid mistakes  
From: clipka
Date: 21 Jul 2009 07:50:01
Message: <web.4a65aac997aca271537313280@news.povray.org>
"bgimeno" <bgimeno[at]persistencia[dot]org> wrote:
> I don't know if there is a special case in which a loop of  the variable
> "FooCounter" should remain unchanged.
> But what about a simple detector where the value of "FooCounter" from the
> #while(FooCounter cond) condition does not change when you reach the end of
> the loop?.

First of all, this would require special handling for conditional expressions to
detect the presence of such a construct during parsing.

Furthermore, consider this:

  #declare R = seed(4711);
  #declare Items = 0;
  #while (Items < 10000)
    #declare MyPos = SomeRandomPosition(R);
    #if (SomeCondition(MyPos))
      DoSomething(MyPos)
      #declare Items = Items + 1;
    #end
  #end

Obviously, the problem is more complicated than just checking whether the
variable value actually changes in each loop: Runtime checking won't do, you'd
need code analysis. Also note that the increment may be hidden nested deeply in
macros, so this is not a straightforward check for the existence of a "#declare
FooCounter = ..." somewhere inside the loop.

In my eyes it would be a kludge anyway, so why not heal the leg instead, and add
a proper #for loop - I'm sure we'd have that issue solved then.

(If POV 4 does indeed get a new SDL as promised, I'm quite sure it will not come
without a for loop anyway.)


Post a reply to this message

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