lua-users home
lua-l archive

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


> Thierry Grellier reported a bug in Lua 5.1.1.  The bug only happens in
> functions with more than 255 names/constants.  Then, the interaction
> between contants and table accesses (e.g., "2*a.x") may produce weird
> results. Bellow is an example (all results should be 2).
> [...]

We could write a quick patch for this bug. However, we are considering
a more drastic measure: maybe it would be simpler to remove constant
folding optimization from Lua 5.1.

Currently, I am not sure constant folding is worth the trouble. We had
all kinds of problems with it: division and module by zero, NaN results,
problems with exotic lua_Number types (which may need a state to create
new values), etc. And it adds very little to the language: it is very
easy for the programmer to define suitable local "constants" to avoid
recomputing constant expressions, when needed.

-- Roberto