On Sat, Dec 22, 2007 at 08:59:11AM -0500, John Belmonte wrote:
> On Dec 22, 2007 4:15 AM, Asko Kauppi <[EMAIL PROTECTED]> wrote:
> > - If 'arg' is being phased out at some point (it no longer is needed
> > for anything, really) how to give the unlimited functionality to
> > '...' at the chunk level?
> >
> > - If 'arg' remains, it could work "unlimited" whereas the '...' way
> > would carry the limits.
> 
> To me the solution is simple-- the command line arguments should be
> available as a list via select(1, ...).  In other words the standard
> Lua interpreter passes command line args to the chunk as a list
> argument-- no magic involved.

If you want a chunk (a function) to be called with '...' set to a long
list, you have to do lua_call(L, n, 0) where n is the number of
arguments, and these arguments must be on the stack. T
hus passing a long '...' requires a long stack. 
Passing to the chunk a single table 'arg' costs just 1 stack slot
(actually you need three slots to fill the table, but it is still a constant
not depending on the size of the table).

The lua interpreter, in function getargs() line 114 file lua.c does both. 

I see no way to pass to a function more arguments than the ones that can
be pushed on the stack. I believe the upstreams will drop the idea of
representing arguments passed to a script using '...' and fall back to
the 'arg' table (as it was in lua5.0 IIRC).

Cheers
-- 
Enrico Tassi



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to