lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Sep 30, 2014 at 12:21 PM, Tom N Harris <telliamed@whoopdedo.org> wrote:
> On Wednesday, September 24, 2014 10:07:29 PM Andrew Starks wrote:
>> Does this mean that we're going to loose coroutines? :)
>
> If by "loose" you mean "set free", then yes perhaps it will.
>
> (My apologies. It was too good to pass up.)
>
> But instead of seeing goto as a continuation, what if it's a tail-call?
>
>     function A()
>       local N=0
>       local C=function()
>         N=N+1
>         goto B
>       end
>       N=1+C()
>       ::B::
>       return N
>     end
>     print(A())
>
> Does this print 1 or 2? Assuming a hypothetical Lua that allows such a thing.
>

It prints 1. You've skipped over the assignment instruction.

/s/ Adam