lua-users home
lua-l archive

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



I revisited the way 'switch' was implemented in LuaX, and here's the code.

This approach is imho more "lua-like" than the earlier, based on Eric Tetz's code was. Also, it only consumes the "switch" keyword, and uses neither "case" nor "default".

Comments are welcome, but for those not being there the "last time" have a look at http://archive.neotonic.com/archive/lua-l/browse_frm/thread/3024/13494 thread first. :)

(oops, that was the 'continue' thread, but there's some on switch about the same time..)


BTW, could "do ... end" be used instead of anonymous non-parameter closures? has anyone done that:

--      switch( action, {
--              [DOG_BARK]= do print "Arf!!!" end,
--              [DOG_BITE]= do print "Chomp!" end,
--              [DOG_SLEEP]= do print "Zzzzzz..." end,
--              } ) or print "Default!"

-ak