lua-users home
lua-l archive

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




On Wed, Sep 15, 2010 at 11:35 AM, David Kastrup <dak@gnu.org> wrote:
Fabien <fleutot+lua@gmail.com> writes:

> "foo(bar)(gnu)(gnat)" is understood differently from "foo(bar)\n(gnu)(gnat)".

Huh?  What makes you think that?  Aren't you confusing "\n" with ";"?\

$ lua
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> x=0
> function f() print ("call #"..x); x=x+1; return f end
> foo, bar, gnu, gnat = f,f,f,f
> foo(bar)(gnu)(gnat)
call #0
call #1
call #2
> ^D
$ lua
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> x=0
> function f() print ("call #"..x); x=x+1; return f end
> foo, bar, gnu, gnat = f,f,f,f
> foo(bar)
call #0
> (gnu)(gnat)
call #1
> ^D

The former is three nested calls; the latter is two calls of depth 1.