lua-users home
lua-l archive

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


Hi!

On 05.03.2012 09:07, Eric Wing wrote:

[...]

Do you leave commas out of lists when you write normally?

Actually when I write lists, I'm not usually thinking/writing in
formal/proper English and I omit commas. I think you'll find this is
more common than you realize.

Shopping List:

milk butter eggs flour baking soda

I have slightly reformatted your shopping list example to illustrate my point below ...


P.S. One thing I love about Lua over JavaScript is that Lua's grammar actually makes semicolons optional as opposed to JavaScript which tries to patch things up after the fact with rules for semicolon insertion.

I also really like optional semi-colons. I always see surprise and
delight from people when I tell them that semi-colons are optional in
Lua. They are even flabbergasted when you omit them for commands on
the same line:
x=1 y=2

This only "works" as long as the statements are reasonably simple. In general a single space is not enough to visually separate list items (or statements), especially if the items/statements contain spaces themselves. Your shopping list example nicely proves that. Mandatory semicolons are such a hated feature because one typically writes only one statement per line anyway and ;\n is overkill. So for me the question is not if commas in tables can be made optional (with or without removing function calls without parentheses) but if we should even try.

But to keep the discussion going:
I know that we just removed a special newline rule for Lua 5.2, but maybe commas in tables could be made optional if the elements are followed by a newline ...? That seems to be the most common use case in the given examples.


[...]

-Eric


Philipp
(who likes commas)

p.s.:
Btw, there is a patch[1] for Lua 4.0 which does optional commas in some cases. It's quite small so maybe someone wants to try to port it to a more recent Lua version.

  [1]: http://lua-users.org/wiki/LuaPowerPatchesArchive