lua-users home
lua-l archive

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


On Wed, Jul 6, 2011 at 9:09 PM, David Hollander <dhllndr@gmail.com> wrote:
> Since the local scope does not have table semantics where it is indexable by
> an evaluation:
> local [getname()] = 3
> why not disrequire the use of the 'function' keyword when 'local' is
> present?
> local function success(items, total)
>   reply(client, view.list(items, total))
> end
> local success(items, total)
>   reply(client, view.list(items, total))
> end
> It shouldn't break compatibility with anything. It's basically just the
> removal of additional implicit syntax.
> 'local' implies initialization\definition and bars evaluation. '()' only
> appears in function declarations outside of evaluations.
> When the two appear together there is only one possibility.

The reason is because your code would require a lookahead parser (that
is, a parser that is able to detect a function declaration expression
before any explicit declaration expression) - and since Lua tries to
be as small as possible, this would likely make the interpreter much
bigger. Apart from that, it looks like purely syntactic sugar...