lua-users home
lua-l archive

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


On Jun 11, 2014, at 9:57 AM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:

>> Perhaps what you are saying is that as there are no symbolic
>> constants in Lua, it is not possible to generate optimized switch
>> statements for all but the simplest scenario where the switch cases
>> are literals?
> 
> Exactly. (These cases are not only simplest, but usually considered bad
> code. If we add a switch optimized only for literals, its impact in code
> standards for Lua would be a tragedy...)
> 
> -- Roberto

Perhaps you could elaborate on this point a bit as I feel I am missing something here. Under C switch statements require literal values yet switch statements are widely used and, as far as I know, the use of which is not considered bad code.

In which way does adding symbolic constants allow the optimising of switch statements? How would adding a switch optimised for literals badly impact the code standards for Lua?

Obviously, as I have created a switch patch for Lua (based on computed gotos) I have an interest in understanding the points being raised here! ;)

~pmd