[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.3.0 (alpha) now available
- From: Andrew Starks <andrew.starks@...>
- Date: Fri, 1 Aug 2014 11:50:24 -0500
On Friday, August 1, 2014, Dirk Laurie <dirk.laurie@gmail.com> wrote:
2014-08-01 17:15 GMT+02: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?
>>
>> -- Roberto
>>
>
> 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.
I like this, but why not
table.icopy(from_tbl[, from_idx, num_elements[, to_tbl, to_idx]])
with from_idx, num_elements defaulting to 1,#from_tbl? Then
sequence cloning is simply
to_tbl = table.icopy(from_tbl)
This is very much about preference, but I like this too. I still like my suggestion (not just cause it's mine) the most:
table.icopy(source, destination, [start_i], [end_i], [target_start])
My reasons are:
The start_i is an index and I'd prefer that the end is expressed the same way, instead of as a quantity.
Target start (a1[t]) is least likely to be set and it somewhat changes the purpose from a copy to a copy-shift.
Leaving off the destination seems least likely, and that's why I'd suggest that as second.