lua-users home
lua-l archive

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


> I noticed that the Lua arithmetic operators in 5.4 will not coerce
> strings to numbers ... is my understanding correct? I think this is
> good for performance as it avoids a function call for converting
> values but presumably this is a breaking change for existing code that
> may be relying on this feature?

Coercion is still present through string metamethods. In practice, the
semantics is quite similar to the old one, or even better:

Lua 5.3:
> "10" + 1      --> 11.0

Lua 5.4:
> "10" + 1      --> 11


> Also noticed that var args will now be put into a table - wanted to
> check if this is just an implementation detail - i.e. no user visible
> impact on either Lua or the C API?

As already explained, you can use _ARG; but you can use also any other
name:

  function foo (...=a) print(a.n) end

_ARG is present both for compatibility (the above syntax will not even
compile in older versions) and for the main chunk (which does not have
a header to name this parameter).


> Finally noted the change to handling of upvalues - upvalues are o
> longer reference counted and instead managed as regular GC objects.
> Presumably this doesn't affect performance?

Upvalues were implemented in this way in Lua 5.0, 5.1, and 5.2. Only
Lua 5.3 changed to reference counting. This way (regular GC objects) is
simpler for generational collection, as upvalues also go through the
generations. We did not measure any performance difference.

-- Roberto