lua-users home
lua-l archive

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


On 23/09/2015 16:30, John Hind wrote:
Help Guys!

I wonder if anyone can offer me some help with a powerpatch to the Lua
lexer/parser (lparser.c)?

I have long published a powerpatch which adds "syntax sugar" to default a
missing value in a constructor list to Boolean true, intended for
tables implementing sets, on the analogy of the sugar for lists:

t = {["cat"], ["dog"]}  -- Shortcut for t = {["cat"] = true, ["dog"] = true}

I've always wanted to extend this to:

t = {[cat],[dog]}

So, similarly to keys for methods, you can drop the quotes if the string is
a valid Lua name.

Whatever you think of this as a language innovation (which we can discuss
later when it exists as a powerpatch)
This looks dangerous.
What is

cat = "tiger"
t = {[cat, dog]}

supposed to do ? Is your cat a "tiger" or just an ordinary "cat" ?

Frederic