Ruby parens-free function calls [was Re: Accessing parent objects]

Rick Johnson rantingrickjohnson at gmail.com
Mon Mar 26 21:42:22 EDT 2018


On Monday, March 26, 2018 at 6:11:31 PM UTC-5, Python wrote:
> On Mon, Mar 26, 2018 at 02:19:12PM -0700, Rick Johnson wrote:
[...]
> > Hmm. If "syntax parser rules" could prevent poorly
> > formatted code, then there'd be no need for style guides.
>
> It may be telling that my team has minimal style standards
> for C/C++, and none at all for Python... [We don't feel it
> requires any.]

Hmm, which would indicate to me you're part of a small,
tight-nit group of like-minded folks. However, what works
well for small groups begins to fall apart in larger
social environment.

> > > > No self-respecting professional programmer would ever
> > > > write in such a manner.
>
> I should also have said that I think this assumes a certain
> level of expertise with the language.  We all start out as
> novices with every new language, and may spend a very long
> time there, depending on how much we use it...

Hmm, very true. If only Steven had been more experienced with
Ruby, then he would have known to avoid that pitfall. O:-)

> > Perl is a special case (and thus not a good retort)
> > because the language itself was purposely intended to be
> > cryptic.
>
> I think Larry would disagree with that assessment...

And that's an opinion he gets to have ;-)

[...]

> > IOWs: It's not a bug, dude, it's a feature.
>
> I dunno, this smells a lot like BS.
>
> Ruby touts itself as being a simple language with elegant
> syntax. This thread is my only exposure to it to date, but
> what I've seen here is, frankly, the exact opposite of
> that.

And do you normally judge the worthiness of an entire
language based on one poorly styled non-idiomatic example
created by somone who is (admittingly) not intimately
familiar with the language?

> You should not need a map to distinguish function
> calls from variables,

I agree that the Python mandated empty parens is a nicely
intuitive indication of a func-call, and that's why i use
the empty parens in all my Ruby code (even though Ruby does
not force me to). Hmm, I'm not sure why Matz chose to make
the syntax optional. But whatever his reason may have benn,
i just hold down shift, and strike two keys, and -- whamo --
my coding style is consistent.

> or operands from function arguments,

Agreed. The syntax "foo(x, y, z)" nicely encapsulates
the arguments whereas "foo x, y, z" does not.

> let alone have the latter depend on the position of the
> operator token relative to any whitespace between it and
> the two tokens on either side of it.  That's hard to read,
> complicated, inelegant, and just poor syntax. [My opinion,
> obviously.] That's not enough exposure to decide that the
> language isn't simple and elegant overall, but it certainly
> does induce a strong negative prejudice.

You shouldn't dismiss Ruby over this one little issue. Need
i remind you that Python has its fair share of warts? In
fact, here is one involving Python's implicit self which
occasionally bites even the seasoned pythonista:

    >>> class Foo(object):
    ...     def bar(self, arg1, arg2, arg3):
    ...         pass	
    >>> foo = Foo()
    >>> foo.bar(1,2)
    Traceback (most recent call last):
      File "<pyshell#7>", line 1, in <module>
        foo.bar(1,2)
    TypeError: bar() takes exactly 4 arguments (3 given)

    (A reinactment of programmer mental state follows)

    "Huh?" o_O

    "I gave _three_ arguments, you say?" o.O

    "Wuh-wuh-what?" O_O

    "_THREE_?" #_O

    "What the hell are your talking about Python?" ಠ_ಠ

    "Are you blind?" (╯°□°)╯︵ ┻━┻

    "Cause I'm _looking_ at the freaking code..."  \(°ロ\)

    "And i'm _looking_ at the freaking exception..." (/ロ°)/

    "but what you're telling me just don't add up!" \(`Д´)

    "YOU LIAR!!!"  ┻━┻︵ヽ(`Д´)ノ︵ ┻━┻

    "Okay. Alright. Listen. I _swears_..."  щ(゚Д゚щ)

    "I only gave you *TWO* arguments -- just two!" (屮゚Д゚)屮

    "WOE IS ME!" (´Д`)

    "I'm so terribly vexed!" (>_<)

    "What have i done to deserve this?" ( ´,_ゝ`)




More information about the Python-list mailing list