[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua 5.2 #... proposal and patch.
- From: Tony Finch <dot@...>
- Date: Tue, 3 May 2011 12:13:01 +0100
I sort-of like the idea of #... and ...[n] as replacements for select(),
though I'm afraid Benoit's patch isn't a good starting point. Consider
According to the order of precedence, it should be read as #(...) i.e.
the length of the first extra argument.
Benoit's patch uses a lexical hack which treats #... as a unit without
regard to order of precedence, so (if the patch were finished based on
the current starting point), it would treat the expression as (#...).
Based on a brief look I think it might be easier to get ...[n] working
properly than #... because the former has a simpler relationship to its
However, there are a couple of ways in which I think this idea isn't as
straightforward as it might seem. It introduces an inconsistency between
the lists of varargs values and lists of values returned by functions. At
the moment these are treated the same. For instance, given
function id(...) return ... end
I think we might be better off thinking of this operation in terms of
tuple projection, as a different concept from table indexing.
f.anthony.n.finch <email@example.com> http://dotat.at/
Rockall, Malin, Hebrides: South 5 to 7, occasionally gale 8 at first in
Rockall and Malin, veering west or northwest 4 or 5, then backing southwest 5
or 6 later. Rough or very rough. Occasional rain. Moderate or good,