lua-users home
lua-l archive

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


On Tue, Oct 20, 2015 at 3:47 AM, Tom N Harris <telliamed@whoopdedo.org> wrote:
> On Monday, October 19, 2015 10:30:12 AM Dirk Laurie wrote:
>> The following syntax could be used:
>>
>>     ##             -- select('#',...)
>>     #index      -- select(index,...) when n is an integer
>>
>> All that we would need to sacrifice is the __len metamethod when
>> its argument is an integer, since then "Lua knows what to do".
>
> #index would be a problem because we don't know at compile time if index is an
> integer or something else. The whole point of this would be to fast-track
> access to elements in the argument list.
>
> Rather than add line noise, could we elevate select to a keyword? Or perhaps
> produce an optimizing compiler that knows how to inline the function.
>
> --
> tom <telliamed@whoopdedo.org>
>

I predict that we are more likely to have `...` removed than to have
it become more entrenched a `select`.

If optimization is a real need (data please?) then there are other
solutions that may be considered. One is removing `...` and replace it
with the old `args` table. The implementation could provide exclude
the table from garbage collection, provided that it is not assigned to
anything. I think that LuaJIT has some similar optimization (for
regular tables)?

My biggest complaint, and it is a very small critique, is simply the
awkwardness of typing `select('#', ...)`. `#(...)` would be nicer to
type, but the implications of this are not known to me.


-Andrew