lua-users home
lua-l archive

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

In 5.1 the manual says that
function name()
is equivalent to

It confused me quite a bit when that didn't hold true in table constructors.
I propose allowing this in a table constructor.

{function name()end}
rather than

and possibly even this
rather than

There is no ambiguity, it looks nicer (to me), and it follows the
principle of least surprise, because it follows the rest of the

That would be a simple addition to the language.

Another far off version of the language (Lua 7?) might look like this:
Anything should be allowed in table constructors, including blocks and
flow control, similar to in env do ... end like this:
  if a then b=3
  else b=4

And maybe a new keyword 'value' that almost acts as a return
statement, but puts them in the table like {value1,value2,value3} does
t={if a then value 'hello' end}
print(t[1]) --> hello

Environments and table constructors would be almost identical.

Just a few thoughts.