Re: FOR i ...

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

Chris Bensler wrote:
> 
> Would it break any code if i were simply allowed to exist after the end of the
> loop?
> 
> for i = 1 to 2 do
> end for
> for i = i to 4 do
> end for
> 
> Chris Bensler
> Code is Alchemy

I don't think it would, but then Pete's proposal of allowing a predeclared
integer i won't work (or will do with subtle side effects, which is worse).
The parser will have to decide whether an existing i is a predeclared non loop
variable - probably disallowed, cf CK -, a loop index at the same level - allowed
and reusing that index - or a nesting loop index - disallowed -.

As a result, the i defined last before ex.err is generated will be dumped there,
whether the loop it belongs to was active or no longer is, with its last value.
Not worse that the current state of things.

This wouldn't add another construct to the language, but change the semantics of
an existing one. Not my own preference, because _both_ semantics are useful to
have.

CChris

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

Search



Quick Links

User menu

Not signed in.

Misc Menu