lua-users home
lua-l archive

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


>But: type(('A').byte(2),) will never raise that error
>as there is always at least one value provided
>which will be nil (this syntax is much clearer than
>using surrounding parentheses!)

I don’t see why your trailing comma notation is clearer at all, let alone “much clearer” :-) 

Elsewhere in Lua, e.g. in table creation, the comma is an item terminator, not a separator. 

So my natural reading of your notation would be that call(a,) and call(a) ought to be equivalent, in the same way that {a} and {a,} are equivalent.

On the other hand, the notation ‘an expression in parenthesis is truncated to a single item’ (as confusing as it might be to a novice) clearly denotes ‘something that applies to whatever is inside the brackets’.

Methinks you have discovered something that seems weird at first but is logical enough once explained, and is easily avoided by using the long-established ‘parenthesis as an operator to cast a list to a value’ notation. 

Therefore I suspect that the issue is in the subject line (the word “error” should not be in quotes and the word incorrect is incorrect:-)