lua-users home
lua-l archive

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


> In the 3.2 API this was simple because the API already had the notion of 
> objects for Lua values and functions for operating on these objects. With 
> 4.0 we've lost that, and even the simplest representation requires constant 
> referencing and dereferencing of objects in the array because the class 
> representation could never know when the array might be altered, changing 
> the index of the object it represents. 

It is a common practice, when programming with "stack languages", not to 
change the stack below your own entry point. If you push something in the 
stack, you remove it, and you assume that no one else called from you 
changes that element (unless that element is an explicit parameter). If 
this simple protocol is followed, you can use the stack index instead of a 
lua_Object. (If something similar to this protocol is not followed, there 
is a reasonable chance that the code is wrong even for Lua 3.2: if you 
create too many lua_Objects outside explicit blocks, you got a stack 
overflow...) 

-- Roberto