lua-users home
lua-l archive

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


> On Jul 29, 2016, at 12:34 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 
> 2016-07-29 8:20 GMT+02:00 Thomas Jericke <tjericke@indel.ch>:
> 
>> Anyway I am currently think {(1, 2, 3)} is the more intuitive array
>> constructor syntax. This because (1, 2, 3) is already the syntax for an
>> argument list.
>> To me {(1, 2, 3)} reads like: I have this list here that you should back me
>> into a table please.
> 
> The most intuitive array constructor syntax is
> 
>    Array{1,2,3}
> 

The trouble is this is inefficient. Lua has to construct a regular table, then pass it to the Array() function, which (presumably) then copies the content to an array (how?) .. and then later the first array is GCed. Not good if you repeat 10,000 times. Unless of course you intend to coerce the table in-place into an array, which is not very constructor-y.

—Tim