lua-users home
lua-l archive

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



On 19-Sep-06, at 11:45 AM, Grellier, Thierry wrote:

So, I would prefer to be able to write something like (VHDL flavor, and
yet another even more disturbing keyword :-) knowing that if elseif...
could be reused)
style = "native"
a = { a = 1,
      b = { b = 2,
            c = 1 when style == "native",
                2 when style == "rock",
                0 else
          }
     }

I actually like "when" (although i use it with "otherwise" because "else" is already in use).

But more Lua like would be:

a = { a = 1,
      b = { b = 2,
            c = {native = 1, rock = 2}[style] or 0
          }
    }

By the way, all this discussion over new keywords does strike me as an issue.

I'd suggest that one way of handling it (for token filter folks) would be to
implement a declaration like this:

feature <keyword> ... end

(or maybe:   --$feature <keyword> ... end )

and only do transformations using a keyword if it had been declared in
a feature statement in that chunk. (The workaround for the standalone
interpreter would be a hook that prepended an appropriate feature
declaration to every chunk passed to the compiler.)