S.Z. wrote:
> Hi, everybody!
>
> Jan Svitok ڧѧ():
>
> > With mandatory parentheses this would be:
> > class Whatever
> >   attr_reader(:attr1)
> > end
>
> Yes, this would be less attractive than without parentheses, I think.
> But. What the rule is? When and where to use parentheses, and where
> not?
> My point is:
> 1) such methods as require, attr_reader, before_filter need no
> parentheses;

Yes.

> 2) such methods as DRb::start_service or join need empty parentheses --
> like start_service() or join();

No, they don't.

> 3) methods with one String argument like puts "Hello!"  or p
> self.inspect need no parentheses;

Correct again.

> 4) p with two or more arguments or with one argument of type different
> from String need parentheses.

Did you bother to check this?

Parentheses are required in Ruby only where ambiutities may occur. This
will trigger a warning as priority may be changed leading to different
interpretations of ambiguous forms. As an example:

a = b = 2 # Set both
p p a, b # Triggers warning

The second line could be read p(p(a,b)) or p(p(a),b). As it happens it
makes no difference in this example which way it is read, but it can be
important. This is the only case where the Ruby language actually
requires parentheses, although in many other circumstances it may be
easier to read with them.

I prefer the lack of parentheses for the first function on a line. I
always parenthesise functions passed as an argument to another even
where only a single argument is taken though.