[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: The meaning of 'sugar' [Forked from Re: Why do we have ipairs?]
- From: Paige DePol <lual@...>
- Date: Wed, 11 Jun 2014 19:44:56 -0500
On Jun 11, 2014, at 9:57 AM, Roberto Ierusalimschy <firstname.lastname@example.org> 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! ;)