lua-users home
lua-l archive

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


The Lua 5.2 manual says:

-----
    void lua_concat (lua_State *L, int n);

Concatenates the n values at the top of the stack, pops them, and
leaves the result at the top. If n is 1, the result is the single
value on the stack (that is, the function does nothing); if n is 0,
the result is the empty string. Concatenation is performed following
the usual semantics of Lua (see §3.4.5).

3.4.5 – Concatenation

The string concatenation operator in Lua is denoted by two dots
('..'). If both operands are strings or numbers, then they are
converted to strings according to the rules mentioned in §3.4.2.
Otherwise, the __concat metamethod is called (see §2.4).

3.4.7 – Precedence

The concatenation ('..') and exponentiation ('^') operators are right
associative.
-----

However, an experiment involving code that calls lua_concat on a table of
objects with metamethods that print information about their arguments, reveals
that table.concat in fact does the concatenation from left to right.