[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Break statement, again.
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Thu, 2 Sep 1999 11:59:11 -0300 (EST)
>From firstname.lastname@example.org Thu Sep 2 11:51:58 1999
>From: Fred Bertsch <email@example.com>
>Here's another possibility that wouldn't require extending the language at
>all. If you add a tail-recursion optimization, you could make a loop look
>local Loop = function( i )
> [ loop code ]
> if( i == %endvalue ) then
> [ more loop code ]
> Loop( i + %increment )
>Loop( startvalue )
>That would give me everything I'd need.
It might work for you, but this solution requires 2 variables external to
the loop (endvalue and increment) -- but you say that this is A Good Thing.
More seriously, you cannot assign to local variables inside the loop,
only to global variables. This would be an ungly restriction for loops.
Of course, you can always use a table as an upvalue and then assign fields
of it inside the loop. That would work.
About tail-recursion optimization, we already have an opcode for this.
We just don't check whether we can re-use the stack.
We'll be discussing this for the next version.