lua-users home
lua-l archive

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


I actually wouldn't mind if all there was is   name = function() end

even in _javascript_ i find my self doing that constantly.

it's more descriptive of what's really going on.



On Mon, Aug 23, 2010 at 8:50 PM, Jonathan Castello <twisolar@gmail.com> wrote:
On Mon, Aug 23, 2010 at 5:41 PM, RJ Russell <russellsprouts2@gmail.com> wrote:
> In 5.1 the manual says that
> function name()
> end
> is equivalent to
> name=function()
> end
>
> 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
> {name=function()end}
>
> and possibly even this
> {function[anyvalue]()end}
> rather than
> {[anyvalue]=function()end}
>
> There is no ambiguity, it looks nicer (to me), and it follows the
> principle of least surprise, because it follows the rest of the
> language.
>
> That would be a simple addition to the language.

If it's important to me, I prefer to just use "function table.method()
end", outside the constructor. The dropped "in some_env do ... end"
statement is probably closest to what you're asking for, though.

> 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:
> something={
>  if a then b=3
>  else b=4
>  end
> }

Looks like Ruby to me.

~Jonathan