[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Ternary operator patch
- From: Ricardo Ramos Massaro <ricardo.massaro@...>
- Date: Wed, 15 Sep 2010 17:16:40 -0300
On Wed, Sep 15, 2010 at 4:33 PM, David Kastrup <dak@gnu.org> wrote:
> It would have taken you 10% of the time for writing the above
> speculation to actually try it out.
Again, I'm not sure I understand what you're saying, I don't see your point.
--- test1.lua ---
print("1")
a = f(g).x(a)
print("2")
a = f; (g).x(a)
--- end ---
--- test2.lua ---
a = f
(g).x(a)
--- end ---
This shows that the two lines [A] and [B] in my example are OK:
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> f = function(x) return { ["x"] = function () print("hello A") end } end
> g = { ["x"] = function () print("hello B") end }
> dofile("test1.lua")
1
hello A
2
hello B
The following shows the "no line break before `(' for function call" rule:
> dofile("test2.lua")
test2.lua:3: ambiguous syntax (function call x new statement) near '('
stack traceback:
[C]: in function 'dofile'
stdin:1: in main chunk
[C]: ?
It this rule didn't exist, Lua would print "hello A" instead of (the
"expected") "hello B", because line breaks are (otherwise) ignored.
> Lua refuses to see those two lines either way and throws a syntax error
> instead.
Well, that's the whole point of the "no line break before `('" rule.
- Ricardo
- 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, David Kastrup
- Re: Ternary operator patch, Juris Kalnins
- Re: Ternary operator patch, David Kastrup
- Re: Ternary operator patch, Ricardo Ramos Massaro
- Re: Ternary operator patch, David Kastrup