lua-users home
lua-l archive

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


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
this expression:

	#...[1]

According to the order of precedence, it should be read as #(...[1]) 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 (#...)[1].
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
subexpressions :-)

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

compare

	#...
	#id(...)
	...[n]
	id(...)[n]

I think we might be better off thinking of this operation in terms of
tuple projection, as a different concept from table indexing.

Tony.
-- 
f.anthony.n.finch  <dot@dotat.at>  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,
occasionally poor.