lua-users home
lua-l archive

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


-----Original Message-----
From: RLake@oxfam.org.pe [mailto:RLake@oxfam.org.pe]
Sent: Thursday, April 29, 2004 6:24 PM
To: Lua list
Subject: Re: Question about LUA_MASKRET

> 1) If the return were actually a tailcall, there would be no practical way to hook before the locals were cleared. 

Makes sense.

> 2) There is nothing in principle stopping a Lua interpreter from overwriting arbitrary locals while computing return values. Defining a return hook the way you apparently think it should be would preclude this optimisation. 

Another good reason.

> 3) Related to the above point, conceptually there are no locals at the point where the return is happening (possibly aside from the function parameters). The expression return statement is executed after the return values are computed, and there are no remaining locals in scope after that. This might be clearer if you think of a stack machine implementation. 

I knew there were good reasons behind this implementation decision, and now I have three =) And from a user standpoint, there is no real benefit to seeing whether some locals were changed by the last statement in a function, as right away those locals will go out of scope, and will be cleared.

> If you want to examine the locals before the entire return statement executes, you should probably use a line hook. 

Yes, I've always used a line hook. I've just been curious whether or not it was possible to view the values of locals after (rather than before) the last statement in a function.

Tai