[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: ... can't be upvalue?
- From: David Kastrup <dak@...>
- Date: Thu, 30 Aug 2007 13:47:15 +0200
David Kastrup <dak@gnu.org> writes:
> Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> writes:
>
>>> Is there a rationale for this behavior, or does it just happen to
>>> be this way?
>>
>> http://lua-users.org/lists/lua-l/2007-03/msg00249.html
>
> Well, this does not exactly give a rationale. It just says that this
> is unlikely to change for what appears to be technical reasons.
>
> Whether those should win over usage consistency is a different
> question in my opinion.
>
> As it is, one has to change
>
> function()
> for i=1,select('#', ...) do something(select(i, ...))
>
> to
>
> local args={...}
>
> function()
> for i,x in ipairs(args) do something(x)
>
> and this seems somewhat unelegant.
On a different tack: maybe one could optimize usage like
for i=1,#{...} do something(({...})[i])
to not actually create tables in order not to have to use select at
all? That would make for more consistency in a different area.
Incidentally, {...}[i] is not allowed.
--
David Kastrup