lua-users home
lua-l archive

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


Soni They/Them L. <fakedme@gmail.com> wrote:

> I've checked the asm output of rustc over and over. It doesn't have jump
> tables. I couldn't get it to produce jump tables no matter what I tried.
> 
> Jump tables are unnecessary. The syntax sugar is nice when comparing the
> same variable to many many values, as it avoids typos (e.g. `hello == 1`
> in the first "if", `helo == 2` in the second "if").

I like my patch which uses jump tables to allow both computed goto syntax
along with faster code branching over a large number of possible choices,
as well as the ability to fallthrough case blocks, which can not currently
be done with just an if/else construct in vanilla Lua.

You are, of course, more than welcome to develop your own patch for creating
a switch/case patch which is just syntactic sugar for an if/else construct.

I may add non-constant case values at some point, if I do maybe I'll revert
the entire switch/case to if/else, or maybe just give const values priority
over non-constant values... but honestly, at this point adding support for
non-constant values is not a priority as there is always if/else for them!

I do agree that switch/case syntax does help remove potential typos in the
names of variables... then again, so would a 'strict' mode! ;)

~Paige