lua-users home
lua-l archive

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

Suppose you want a function that returns 10 indices from a table stored in 
a global 't'. The main point is: you don't want to do getglobal ten times. 
You want to do it once, and keep that temporary value in the stack *while* 
you access the ten elements. (The stack in the API allows you to access 
elements inside it; only modifications follow a strick stack disciplinne.) 
When you finish, the table is still in the stack, *below* the ten values 
you want to return. Then you either need extra stack-manipulation functions 
(such as rotate) to remove the extra element, or you simply say "return 

This is not a special case. There are many other cases where you must
keep intermediate values while you compute the final results, and those
intermediate values will always be below the final results.

-- Roberto