[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Idea: 'function' keyword optional when preceded by 'local'
- From: Dirk Laurie <dpl@...>
- Date: Thu, 7 Jul 2011 09:12:02 +0200
On Thu, Jul 07, 2011 at 08:11:03AM +0200, steve donovan wrote:
> I like David M's suggestion of
>
> local f(x,y) = x+y
>
> (memories of Fortran statement functions)
And of C #define. Its meaning should be intuitively obvious to nearly
everyone.
This is the only suggestion in this thread, so far, that looks like
future Lua to me, as distinct from past Perl, Ruby, etc.
Five extra lines in the manual:
> The following syntactic sugar simplifies function definitions:
>
> stat ::= function funcname funcbody
> stat ::= local function Name funcbody
+ stat ::= local Name `(´ [parlist] `)´ = exp
> funcname ::= Name {`.´ Name} [`:´ Name]
...
+ The statement
+ local f() = exp
+ translates to
+ local function f() return exp end
Dirk