From: "David A. Black" Date: 2009-10-05T19:23:41+09:00 Subject: [ruby-core:25939] Re: [Feature #2131] f(not x) => syntax error Hi -- On Mon, 5 Oct 2009, James M. Lawrence wrote: > Issue #2131 has been updated by James M. Lawrence. > > > 09/23/2009 06:26 PM - Yukihiro Matsumoto: >> |This should have been classified as a feature request. >> | >> |Since (not x) is legal syntax, it is my opinion that f(not x) should be legal. >> >> So, do you mean a,b,c = 1,2,3 is legal syntax, should we allow >> f(a,b,c = 1,2,3) ? > > That (a,b,c = 1,2,3) and f(a,b,c = 1,2,3) contain different meanings > inside the parens does not really affect my argument. > > [0] + (a, b, c = 1, 2, 3) # => [0, 1, 2, 3] > > Whether that should mean [0, a, b, 1, 2, 3] or something else is a > different matter. > > My point is that the parens serve to disambiguate, > > [0] + a, b, c = 1, 2, 3 # => syntax error > [0] + (a, b, c = 1, 2, 3) # => [0, 1, 2, 3] > [0] + f a, b, c = 1, 2, 3 # => syntax error > [0] + f(a, b, c = 1, 2, 3) # => ok > > true | not false # => syntax error > true | (not false) # => true > true | f not false # => syntax error > true | f(not false) # => syntax error > > Why should the last case fail? I also see no reason why > > f(class Foo;attr_accessor :x;end;Foo.new.x=5) # => syntax error > > should necessarily be illegal. It's just f(5) with a side-effect. > The parens are fully capable of capturing the expression. One case that comes to mind is: f(class Foo; attr_accessor :x; end; Foo.new.x = 5,6) Is 6 a second argument to f, or a second argument to Foo#x= ? David -- David A. Black, Director Ruby Power and Light, LLC (http://www.rubypal.com) Ruby/Rails training, consulting, mentoring, code review Book: The Well-Grounded Rubyist (http://www.manning.com/black2)