[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Parentheses

Volkmann, Mark

10/15/2003 6:18:00 PM

I like Kirk's criteria for deciding when to use parens. The ability to omit
them is one of the reasons I prefer Ruby syntax over Java syntax. The less
noise, the better.

> -----Original Message-----
> From: Kirk Haines [mailto:khaines@enigo.com]
> Sent: Wednesday, October 15, 2003 1:00 PM
> To: ruby-talk@ruby-lang.org
> Subject: Re: Parentheses
>
>
> Bob Gustafson said:
> > I prefer the parentheses.
> >
> > Parens are an 'ambiguity reducing notation' - without the
> parens, you have
> > to ask (from time to time) - "What is the precedence of
> these operators in
> > this language".
> >
> > Less ambiguity means clearer (human) code.
>
> I think that it depends.
>
> #1
> -----
> dbh.select_all sql do |row|
> media_list.push QMedia.new *row
> end
> -----
>
> #2
> -----
> dbh.select_all(sql) do |row|
> media_list.push(QMedia.new(*row))
> end
> -----
>
> I think that #1 is easier to read than #2. However, consider:
>
> #3
> -----
> dbh.select_all sql,@client.idx do |row|
> media_list.push QMedia.new me.idx,row[0],row[1]
> end
> -----
>
> #4
> -----
> dbh.select_all(sql,@client.idx) do |row|
> media_list.push QMedia.new(me.idx,row[0],row[1])
> end
> -----
>
> If there are multiple arguments, I prefer to use parens to
> group them and
> help make it clearer to my eyes where the groupings are.
>
>
> Kirk Haines
>
>


------------------------------------------------------------------------------------------
A.G. Edwards & Sons' outgoing and incoming e-mails are electronically
archived and subject to review and/or disclosure to someone other
than the recipient.

------------------------------------------------------------------------------------------