The point of omitting parentheses

Phrogz wrote:

Henrik S. wrote:

Wow, public, private and protected are actually method call. I wonder
how they implemented that. Now I HAVE to get the source code. :slight_smile:

See if the following helps: code in classes isn’t compiled, it is
executed. Defining a function is a discrete step that runs (and returns
nil), and that you can listen for.

Got it. That’s pretty cool. Thanks for the help.

Best Regards,
Henrik S.

I feel like such a n00b – I don’t think I’ve ever created a DSL and
don’t expect to in the near future.

Joe

On Thu, 21 Sep 2006 23:52:03 +0900
“Wilson B.” [email protected] wrote:

that they are ugly.

I only use them in two places, personally:

  1. When the left-hand side of a ternary starts to look scary:
    x = (foo == baz.something) ? this : the_other

  2. Method definitions, since I find they draw the eye better than
    without. def thingy x, y, *z, &block vs. def thingy(x, y, *z, &block)

Like everyone else who has replied to this thread – they’re either
explicitly stated or alluded to the fact that it’s purely a matter of
choice.

For me, it’s useful to fit my mindset as to what makes things clearer
for me. For years, I have been using Java, and I do find the use of
parenthesis around method calls useful in Ruby to make me realise
what’s going on. But it’s just choice.

When you consider things like:

require ‘foo’
attr_reader :myvar

Those dictate properties if you will of the class, so not adding
parenthesis around them makes sense, despite them being methods in
their own right.

– Thomas A.

On Fri, Sep 22, 2006 at 04:46:29AM +0900, Joe R. MUDCRAP-CE wrote:

I feel like such a n00b – I don’t think I’ve ever created a DSL and
don’t expect to in the near future.

You do, you have, and you will: a library with a well-designed API is
essentially a DSL.

Keith G. wrote:

On Fri, Sep 22, 2006 at 04:46:29AM +0900, Joe R. MUDCRAP-CE wrote:

I feel like such a n00b – I don’t think I’ve ever created a DSL and
don’t expect to in the near future.

You do, you have, and you will: a library with a well-designed API is
essentially a DSL.

Phew! It’s good to know I’ve been buzzword-compliant all these years. :stuck_out_tongue_winking_eye:

Joe

Thomas A. писал(а):

Like everyone else who has replied to this thread – they’re either
explicitly stated or alluded to the fact that it’s purely a matter of
choice.
My this year point is as follows:
To use or not to use – is a matter of taste.
To have a rule for doing either – is a matter of clear writing.
To use an appropriate rule – is a matter of productivity.
Constantly improve the rules – is a metter of progress.

Best respects,
S.Z.

On 9/20/06, Phrogz [email protected] wrote:

One of the greatest reasons for omitting parentheses is that the
syntactic sugar allows you to write code that looks like you’re
assigning values to properties and reading those properties, when in
reality you’re calling methods.

f.bar = 12
puts( f.bar )

Or hell,

x = 5

If you used parenthesis around every method call, this would be
x=(5)

How does that work, actually? method_missing?