lua-users home
lua-l archive

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


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