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 02:56:49 EDT (-0400)
  Re: I want to be rid of my stupid mistakes  
From: clipka
Date: 21 Jul 2009 08:20:00
Message: <web.4a65b21097aca271537313280@news.povray.org>
"scott" <sco### [at] scottcom> wrote:
> Impossible to catch all infinite loops, but the parser could check to make
> sure at least one of the variables mentioned in the #while condition is
> reassigned within the loop.  That would catch a lot of mistakes (eg
> forgetting to increment the index variable).

What if we're talking about a loop like this:

  #declare abortProb = 0.03;
  #while(rand(R) > abortProb)
    //...
  #end

Still insist on the variable being re-assigned? What if not rand() is used, but
some macro creating a non-uniform distribution?

What if no variable is used at all, as in:

  #while(rand(R) > 0.03)
    //...
  #end


I do know I keep repeating myself, but: Why on earth try to come up with
ever-so-complex ways to detect a broken counting #while loop without breaking
other uses of the #while statement, when really the root problem is the absence
of a proper #for loop?

Virtually no-one is asking for an infinite loop detection in other languages
like Pascal, C, VB or what-have-you. Why? Because they do have a for-loop so
you usually don't encounter this blunder there.


Post a reply to this message

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