|
|
"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
|
|