lua-users home
lua-l archive

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


> PiL, 2nd ed., 27.3, implements a more minimal form of that same idea.  (PiL also
> omits the n <= LUA_MINSTACK check, which I think is ok.)

Actually, only tupleF and newtuple are necessary; the remaining methods are
just for convenience.
 
> Your example does illustrate a case where it would be useful for different
> functions to have different metatables.  #t should have different behaviors
> depending on whether the closure t represents a tuple or something else.  An
> alternative is to wrap the closure in a table or, maybe, multiplex the function
> metatable.

#t is sugar for t(0), while t[i] is sugar for t(i, i), but __eq would be
really nice to have for comparing tuple upvalues (I do have __eq for tuples in
case Lua 5.2 supports it. :))

Cheers,
Luis.

-- 
A mathematician is a device for turning coffee into theorems.
        -- P. Erdos 

-- 
Luis Carvalho
Applied Math PhD Student - Brown University
PGP Key: E820854A <carvalho@dam.brown.edu>