lua-users home
lua-l archive

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

Hi list,
I hit upon a construct using tables trying to solve the problem of how
to represent mutually exclusive values in a straightforward manner
without relying on control flow statements or function definitions.  I
use this mostly in Lua scripts that represent data of some kind, which
motivates the desire to rely solely on tables.  In the code below,
it's for holding platform-dependent data such as compilation flags
used by gcc on various platforms.  I haven't run across code like this
before, so I thought I'd pass the idea along.

-- set the field flags according to the value held in OS
flags = ({
   OSX = {
      -- OSX flags
   LINUX = {
    --  Linux flags
   WIN32 = {
      -- Windows flags