lua-users home
lua-l archive

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





On Thu, Jul 31, 2014 at 3:46 PM, Coda Highland <chighland@gmail.com> wrote:
On Thu, Jul 31, 2014 at 1:39 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> ---
> table.copy (a1, f, e, [a2,] t)
>
> Copies elements from table a1 to table a2. This function performs the
> equivalent to the following multiple assignment: a2[t],··· =
> a1[f],···,a1[e]. The default for a2 is a1. The destination range can
> overlap with the source range. Index f must be positive.
> ---
>
> I have mixed feelings about this. Last year [1] John Hind and I
> wrote a module called "xtable" containing a function block.move
> such that when e>=f,
>    block.move(a1,f,e,t)
> does exactly what the above definition of
>    table.copy(a1,f,e,t)
> does. So I should be very pleased. However, I am not delighted
> by an optional argument preceding a non-optional one. It violates
> my sense of conceptual integrity.
>
> [1] <http://lua-users.org/lists/lua-l/2013-04/msg00016.html>
>

You know, maybe the resolution is to define separate move() and copy()
functions, where move() doesn't accept a destination, and copy()
requires one.

/s/ Adam


But my read of the documentation tells me that the original values remain. Is that not the case? If it is, then move is more confusing, to me. 

-Andrew