lua-users home
lua-l archive

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


2015-09-24 12:12 GMT+02:00 John Hind <john.hind@zen.co.uk>:

> t = {.cat, .dog} --> t = {['cat'] = true, ['dog'] = true} (or t = {cat =
> true, dog = true}).
> t = {[cat],[dog]} --> t = {[cat] = true, [dog] = true}
>
> And, for regularity:
>
> t = {.cat = true, .dog = true} -- Dot prefix should be allowed, but not
> required, for a name = value declaration
> (any value).

Reminds me of Scheme/Guile. This is not a point either for or
against, just an observation.

...
> Lua is billed as "offering an expressive syntax for creating tables" and "a
> powerful general-purpose procedural
> data-description language" (1), so the expressiveness and brevity of table
> constructors is a valid discussion.

Personally, I don't use `true` but `1`. You beat me on brevity by one
character per element, but I beat you on expressiveness, since my
usage generalizes to multisets.