lua-users home
lua-l archive

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


>> ... may be an expression, but the question is: what does # do when
>> applied to multiple values? It can discard all of them except the
>> first, or it can count them.
>> 
>> Given the second interpretation, #{whatever} and #"whatever" work as
>> now, but #... returns the count of arguments; 

> And what if ... *is* only a single item?

I began this thread talking about syntax. #... is syntactically
different than #(...) and both the compiler and programmer can expect
# to be applied to multiple values in the first case, and one value in
the second. To the compiler it is unknown and irrelevant how many
values there will be at run time.

> Also, there will be situations where you can get very unexpected results:
>
>      #string.gsub(a, b ,c)  -- this is always 2!

That was not my proposal.
This syntax is not #... it is # <function call>.

The debate seems to be between those who like #... as special syntax
for "length of multiple value arguments," and those who read it as
"operator # applied to the first value in the multiple value
arguments."

e