lua-users home
lua-l archive

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


----- Original Message -----
From: Alexander Gladysh
Date: 12/21/2011 7:42 AM
On Wed, Dec 21, 2011 at 18:25, Joshua Jensen<josh.jjensen@gmail.com>  wrote:
----- Original Message -----
From: Philippe Lhoste
Date: 12/21/2011 6:19 AM
On 17/12/2011 13:47, Jeff Smith wrote:
6) I dont like long if else blocks, so a select case construct would have
been nice IMHO.
This is usually done with a table of functions, no? A bit verbose, but
quite usable.
And MUCH slower.
Only about 15 times slower (with vanilla Lua), AFAIR, but much more readable.

In rare cases where that 15 times matter, you always can rewrite to
whatever is more efficient .

I publish games. I care about performance. I am willing to sacrifice some performance by using a scripting language, but when a construct can be created that enhances performance over the alternative, like a switch statement over a table of functions, I am for it.

The Lua C source code itself uses switch in dozens of places. The result is plenty readable and arguably far more readable than a table of functions that have to be defined elsewhere in the file.

-Josh