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 Russell
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]

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.

···

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

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

--
Ross Bamford - rosco@roscopeco.REMOVE.co.uk

Ross Bamford 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

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

-Robby

Robby Russell
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 Apr 24, 2006, at 1:35 AM, Dave Burt wrote:

Ross Bamford 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.

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

···

On 4/24/06, Robby Russell <robby.lists@planetargon.com> wrote:

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

> Ross Bamford 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.
>

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

-Robby

Robby Russell
Founder & Executive Director

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

www.planetargon.com
www.robbyonrails.com

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

Hi --

···

On Tue, 25 Apr 2006, Patrick Hurley 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 (dblack@wobblini.net)
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!

Maybe :slight_smile:

<tongue in cheek>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

···

On 4/24/06, dblack@wobblini.net <dblack@wobblini.net> wrote:

Hi --

On Tue, 25 Apr 2006, Patrick Hurley 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 (dblack@wobblini.net)
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!