lua-users home
lua-l archive

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


On Sat, Mar 3, 2012 at 1:11 PM, Greg <tghill@hotmail.com> wrote:
> Occasionally I forget commas when I create large nested tables in Lua.  It
> reminds me of when I was learning c and always forgetting to place semicolons at
> the end of a line.  I'm so happy that semicolons are optional in Lua.  I wish
> commas were too.
>
> Could this work?

Unfortunately it would introduce ambiguities. Lua supports a mix of
key-value table syntax and array-style table syntax, and also supports
optional parentheses in function calls when calling with a single
string or table literal parameter. So for example, if
commas/semicolons between table fields were optional, {a = b "test"}
could be either {a = b; [1] = "test"} or {a = b("test")}. There are
probably other ambiguities too.

-Duncan