Forum: Ruby Future of parenthesis?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Robby R. (Guest)
on 2006-04-24 06:43
(Received via mailing list)
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. :-)

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

-Robby

--
Robby R.
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]
Ross B. (Guest)
on 2006-04-24 11:43
(Received via mailing list)
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. :-)
>
> 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.
Dave B. (Guest)
on 2006-04-24 12:38
(Received via mailing list)
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
Robby R. (Guest)
on 2006-04-24 20:17
(Received via mailing list)
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.planetargon.com
www.robbyonrails.com

+1 503 445 2457
+1 877 55 ARGON [toll free]
+1 815 642 4968 [fax]
Patrick H. (Guest)
on 2006-04-24 21:01
(Received via mailing list)
On 4/24/06, Robby R. <removed_email_address@domain.invalid> 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
unknown (Guest)
on 2006-04-24 21:07
(Received via mailing list)
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? :-)


David

--
David A. Black (removed_email_address@domain.invalid)
Ruby Power and Light, LLC (http://www.rubypowerandlight.com)

"Ruby for Rails" PDF now on sale!  http://www.manning.com/black
Paper version coming in early May!
Patrick H. (Guest)
on 2006-04-24 21:23
(Received via mailing list)
On 4/24/06, removed_email_address@domain.invalid 
<removed_email_address@domain.invalid> wrote:
>
>
Maybe :-)

<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
:-)

pth
This topic is locked and can not be replied to.