Re: trace(1) bug

new topic     » goto parent     » topic index » view thread      » older message » newer message

Andy Drummond wrote:
> c.k.lester wrote:
> > Right now the interpreter protects programmers from making this mistake. If
> > you want to be able to use an already-declared variable in a for loop, make
> > a new way to iterate. Don't mess with for...end for!
> What you say is true, of course. It just seems odd that a variable created
> within and scoped only to a for-next loop precludes that variable being what
> is effectively a non-local variable. It's as if using a local variable x
> stopped you having a global variable x - of course it doesn't; you use the
> global x or a local x. If you use the global x and change it then the global
> x changes!

Do you mean if I reuse a variable in a for loop, it
should be considered local to that for loop?

i = 324
for i=1 to 10 do
  ?i -- 1,2,3,4,5,6,7,8,9,10
end for
?i -- 324

What if I want to use the i that equals 324 in the loop?

Anyway, my point is I would never want to use a pre-defined variable
in a for loop, and neither would anybody else. :D

> I will accept what you say - that if people code wrong they will get wrong
> results. But why force procedures that complicate matters - and require more
> variables - just so that people can use already defined variables a second
> time without fouling up the earlier usage. Surely it isn't too much to expect
> programmers to use different variables for different values?

What are the benefits of allowing the use of a pre-declared var in a loop?

Of course I want Euphoria to improve. :)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu