lua-users home
lua-l archive

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


[Let me get out my Language Lawyer costume.]

On Dec 9, 2012, at 3:45 AM, Dirk Laurie wrote:

> The Lua 5.2 manual says:
> 
>    void lua_concat (lua_State *L, int n);

>  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.

This does not specify order of evaluation. It may not be germane, as concatenation is not necessarily tied to a concatenation *operator*. But separating the documentation of the two would probably be a good idea.

> 3.4.7 – Precedence
> 
> The concatenation ('..') and exponentiation ('^') operators are right
> associative.

Associativity does not specify order of evaluation, just the implicit parentheses.

> table.concat in fact does the concatenation from left to right.

Order of evaluation is undefined, according to this conversation between Mike and Roberto:

http://lua-users.org/lists/lua-l/2006-06/msg00378.html

>> I'd like to have a definitive statement from the Lua authors
>> whether the Lua language as of version 5.x has a defined
>> evaluation and assignment order (with respect to side-effects) or
>> whether it is explicitly undefined. Also whether there is any
>> guarantee about the semantics of future versions.
> 
> Evaluation order and assignment order are both explicitly undefined.