From: Ross Bamford Date: 2006-04-24T16:42:33+09:00 Subject: Re: Future of parenthesis? On Mon, 2006-04-24 at 11:42 +0900, Robby Russell wrote: > I've been seeing people mention the following warnings. > > > warning: parenthesize argument(s) for future version > > For example... some people are blogging and nobody seems to know. :-) > > http://jroller.com/page/obie?entry=dslish_ruby_hacks_the_as > > Can someone give some insight to the future of Ruby and parenthesis? I'm > curious... :-) I'm not entirely sure, but I think this warning is about slightly stricter parsing in future ruby versions, to reduce ambiguities like this: p Array.new 3, 1 (irb):3: warning: parenthesize argument(s) for future version [1, 1, 1] (i.e. is it p(Array.new(3,1)) or p(Array.new(3),1)). It may be that future versions will introduce features or change the parser such that unadorned arguments like the above are treated 'incorrectly' (when compared to now), but that's just speculation on my part). I think it's related to this one (in 1.8.x, 1.9 doesn't seem to care?): p Array.new (3+1), 1 (irb):5: warning: don't put space before argument parentheses [nil, nil, nil, nil] 1 # => nil (i.e. is it argument parens or a subexpression). This can help trace subtle problems in your code, e.g. p Array.new (3 + 1) / 2, 1 (irb):11: warning: don't put space before argument parentheses NoMethodError: undefined method `/' for [nil, nil, nil, nil]:Array from (irb):11 p Array.new((3 + 1) / 2, 1) [1, 1] # => nil I don't think (or I hope not, anyway) that ruby will require parens on all method calls, only where method calls are made involving other method calls as arguments. -- Ross Bamford - rosco@roscopeco.REMOVE.co.uk