On Sat, Mar 17, 2018 at 7:39 PM, Jay Carlson wrote:
> New syntax {...#} is used for constructing a table
> with its "user-specified length" set to actual data length.
>
> Probably, syntax {...#} is not nice.
I wonder how much code would break by replacing the existing
meaning of #{}.
...
For completeness, add the sugar:
f#{math.pi} <=> f(#{math.pi})
The syntax I suggest is {...#}, not #{...}
#{...} should have the old meaning, as I don't want to break old Lua code.
All Lua 5.3 programs would be runnable on Lua 5.4 VM without
modifications.
But in 5.4 new incompatible syntax {...#} would exist for new semantics.
All the discussions about Lua table length issues are in the context
of arrays.
Table length is undefined for dictionaries.
IMO, only sequential part should be counted for {...#} constructor.
Example: the length of non-sequence table such as
{ 1, 2, 3, [4]=4, [42]=42 #}
depending on the implementation, may be 3.
assert( #{ 1, 2, 3, [4]=4 } == 4)
assert( #{ 1, 2, 3, [4]=4 #} == 3)