lua-users home
lua-l archive

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


2014-08-01 16:15 GMT+01:00 Daurnimator <quae@daurnimator.com>:
> On 1 August 2014 10:48, Roberto Ierusalimschy <roberto@inf.puc-rio.br>
> wrote:
>>
>> >  [...] However, I am not delighted
>> > by an optional argument preceding a non-optional one. [...]
>>
>> We do not like it either. Do you suggest any alternative?
>
> I see no problem saying making the function signature
>
>     table.icopy(from_tbl, from_idx, num_elements, [to_tbl, to_idx])
>
> If to_tbl and to_idx ar not given, they default to the empty table and 1.
> The function always returns to_tbl.

table.insert already has an optional middle argument, I don't see any
issue there (yeah some people complain about it, but some people
complain about virtually anything). And as for the naming, every
single function in the table module already deals only with integer
indices, so I don't see the point in renaming copy to icopy. If you
want to rename something, maybe we should rename the table module to
array.

There's one objective argument in favour of the proposed API: it keeps
the module API consistent. I've yet to see an argument against that
doesn't come down to taste and personal preference.