lua-users home
lua-l archive

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


> That said, I could see arguments for things like folding away the code in an
> "if false" because this form might get used for turning code on and off.
> That in turn perhaps argues for syntax for declaring constants in the code
> that the compiler can then exploit as constants.

Constants are already well served by using locals, but constant folding
cannot work on constant locals. This and dead-code elimination could be
done in a smarter generator, and could be added to luac for instance, to
avoid bloating the core compiler. I think it'd be fairly easy to write an
addon module for luac that identifies constant locals and removes dead code.

Another route for dead-code elimination is to use token filters to identify
"if false then" and "if true then" and remove the dead block. (This needs
some simple block depth counting.)
--lhf