lua-users home
lua-l archive

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


On Wednesday 07 November 2007, Javier Guerra wrote:
 
> sure, i do this all the time (and i'm sure many others).
>
> also, since in Lua functions are really anonymous (unlike Python), it
> doesn't pollute any namespace (the table itself is the namespace)
>
>
> -- easy to write...
> local dispatch = {
>    start = function (x) .... end,
>    continue = function (x) ..... end,
> .....
> }
>
> dispatch[state](x)             -- and easy to call!

  Bingo!
  Thanks
  tj