lua-users home
lua-l archive

Re: predefined constants

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


I am looking at cutting an existing c++ algorithm to lua.
The current c++ version uses a lot (~30) of #defined state flags.
Since it looks like you're about to do a lot of dispatching based on a state variable that can take several dozen forms, you might consider creating a table that maps each state value to a function to handle that state.
To store / define the various state constants I'd go with strings: using them as indexes (or comparing them, for that matter) is very fast, because Lua stores them only once.
Ashwin.
--
no signature is a signature.

AltStyle によって変換されたページ (->オリジナル) /