Future of parenthesis?

Hey all!

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. :slight_smile:

Can someone give some insight to the future of Ruby and parenthesis? I’m
curious… :slight_smile:

-Robby


Robby R.
Founder & Executive Director

PLANET ARGON, LLC
Ruby on Rails Development, Consulting & Hosting

www.robbyonrails.com

+1 503 445 2457
+1 877 55 ARGON [toll free]
+1 815 642 4968 [fax]

On Mon, 2006-04-24 at 11:42 +0900, Robby R. 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. :slight_smile:

Best Online Casino in Australia | Top Licensed Casinos for Gamblers

Can someone give some insight to the future of Ruby and parenthesis? I’m
curious… :slight_smile:

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 B. wrote:

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.

That’s right. Ruby will certainly never have parens on all method calls
(Matz has said this repeatedly) but the warning is for the obvious
syntactic ambiguities.

I hope this addresses part of OP’s concerns.

Cheers,
Dave

On 4/24/06, Robby R. [email protected] wrote:

calls

+1 877 55 ARGON [toll free]
+1 815 642 4968 [fax]

My understanding from reading this list is that at some point
ambiguous expressions may require parenthesis. However, there is no
intention to disallow simple function calls/dsl syntax.

pth

Hi –

On Tue, 25 Apr 2006, Patrick H. wrote:

My understanding from reading this list is that at some point
ambiguous expressions may require parenthesis. However, there is no
intention to disallow simple function calls/dsl syntax.

Do you predicate that frequency of parentheses on method calls and
dsl-ness vary inversely? :slight_smile:

David


David A. Black ([email protected])
Ruby Power and Light, LLC (http://www.rubypowerandlight.com)

“Ruby for Rails” PDF now on sale! Ruby for Rails
Paper version coming in early May!

On Apr 24, 2006, at 1:35 AM, Dave B. wrote:

I hope this addresses part of OP’s concerns.

So, nothing will be required butt it may still generate a warning?

-Robby

Robby R.
Founder & Executive Director

PLANET ARGON, LLC
Ruby on Rails Development, Consulting & Hosting

www.robbyonrails.com

+1 503 445 2457
+1 877 55 ARGON [toll free]
+1 815 642 4968 [fax]

On 4/24/06, [email protected] [email protected] wrote:

Maybe :slight_smile:

Hey isn’t a dsl just a bunch of function calls
without parenthesis so it fools people into thinking we have expanded
the language?</tongue in cheek>

I would assert that making parenthesis optional in the non-ambiguous
cases is one of the (many) language features that (without my
realizing it at first) drew me to Ruby. What can I say, I have a sweet
tooth and I like my syntax sugar (if I didn’t I would stick with List
:slight_smile:

pth