lua-users home
lua-l archive

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

On Thu, Mar 16, 2017 at 3:31 AM, Nagaev Boris <> wrote:
> On Thu, Mar 16, 2017 at 2:09 AM, Hisham <> wrote:
>> (I've even seen `local append = table.insert` in the wild!).
> It is not very surprising, because Go, Swift and Python call this
> thing "append"

I'm not familiar with go or swift, but I'd like to point Pyhton calls
it INSERT. The difference is the index is not optional and it has
another function called append which does insert-at-end ( to be
expected in a system where you have lists with a defined length
separated from mappings ).
> we already have push_back (C++),

C++ has, i.e. in vector, INSERT ( and push_back too )

> add
> (Java, Javascript, C#), append (Python, Go, Swift), push (Perl, Rust),
> array_push (PHP).

This are ( more or less ) variations of Python's append. The thing is
lua does NOT have append(at end, and generally amortized constant time
in many languages), you have to do it using generic insert(at any
position, including end, amortized constant time in many of those
languages but, IIRC, not in lua ( unless you are caching the length,
which I'll consider cheating  ))

Francisco Olarte.