lua-users home
lua-l archive

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


> I stumbled into this idea while writing a long set-like table. Wouldn't it
> be nice if the following:
>   set = { a = true, b = true, [1] = true }
> could be abbreviated as:
>   set = { ["a","b",1] = true }

I second this idea, it would be a useful addition.
Several times, I would have used such a feature if it was available.
Instead, my preferred method is to use something similar to the
reverse_map() example.
That syntax should be added to Lua if (and only if) it was easy to implement.
Unfortunately, I doubt that the implementation is so easy: it looks
like the parser would have to look ahead an arbitrary number of tokens
before knowing what to do with the first field.