[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Ternary operator patch
- From: Tony Finch <dot@...>
- Date: Wed, 15 Sep 2010 12:19:11 +0100
On Wed, 15 Sep 2010, mauro iazzi wrote:
>
> Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> > function f(x) print('f', x) return f end
> > do
> >> f(1)(f)(3)
> >> end
> f 1
> f function: 0x12963a0
> f 3
> > do
> >> f(1)
> >> (f)(3)
> stdin:3: ambiguous syntax (function call x new statement) near '('
> >
Note this ambiguity has been resolved in 5.2:
Lua 5.2.0 (work3) Copyright (C) 1994-2010 Lua.org, PUC-Rio
> do
>> local x = 0
>> local f = function (a) print("call "..x) x = x + 1 return a end
>> f(f)
>> (f)(f)
>> end
call 0
call 1
call 2
>
A function call statement now maximally munches all trailing argument-like
clauses - bracketed expressions, table constructors, and strings - and is
terminated by a keyword, a variable name, or a semicolon. Newlines are now
treated the same as other white space.
Tony.
--
f.anthony.n.finch <dot@dotat.at> http://dotat.at/
HUMBER THAMES DOVER WIGHT PORTLAND: NORTH BACKING WEST OR NORTHWEST, 5 TO 7,
DECREASING 4 OR 5, OCCASIONALLY 6 LATER IN HUMBER AND THAMES. MODERATE OR
ROUGH. RAIN THEN FAIR. GOOD.
- References:
- Re: Ternary operator patch, Henk Boom
- Re: Ternary operator patch, steve donovan
- Re: Ternary operator patch, Geoff Leyland
- Re: Ternary operator patch, steve donovan
- Re: Ternary operator patch, Miles Bader
- Re: Ternary operator patch, David Kastrup
- Re: Ternary operator patch, Miles Bader
- Re: Ternary operator patch, David Kastrup
- Re: Ternary operator patch, Jonathan Castello
- Re: Ternary operator patch, Roberto Ierusalimschy
- Re: Ternary operator patch, Enrico Tassi
- Re: Ternary operator patch, Doug Rogers
- Re: Ternary operator patch, Fabien
- Re: Ternary operator patch, David Kastrup
- Re: Ternary operator patch, Fabien
- Re: Ternary operator patch, mauro iazzi