lua-users home
lua-l archive

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


on 8/8/07 12:38 PM, Luis Carvalho at carvalho@dam.brown.edu wrote:

>> Proposal 2
>> ----------
>> Leave tables as they are, but introduce more efficient mechanisms than
>> select for dealing with varargs. Specifically, allow:
> 
> <snip>
> 
>> Proposal 3
>> ----------
>> Tuples to capture sequences containing nil. This can be done with functions
>> but they are crude because they don't support #tuple and tuple[ idx ]. This
>> can be done with userdata but it gets a bit expensive and leaves open the
>> question of why one needs to bail out to userdata to work around language
>> "issues".
> 
> I think your proposal 3 would be an implementation of proposal 2 in the sense
> that (functional) tuples could substitute select. Why would you need #tuple
> and tuple[idx]? select does not have them, for instance. With tuples one could
> do:

The lack of support there is one of the things that makes select feel crude.
(The invitation to experience n-squared time complexity is a bigger problem
with select.)

How do we index in Lua? Using []. Unless it's a tuple in which case we use
(). Ugh.

How do we take the length of something in Lua? Using #. Unless it's a tuple
in which case we use ( '#' ). Ugh again.

Of course, both of those ughs apply to the current situation with ... and
select as well.

Mark