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

Rick Johnson rantingrickjohnson at gmail.com
Mon Mar 26 14:37:35 EDT 2018


On Monday, March 26, 2018 at 5:46:03 AM UTC-5, Steven D'Aprano wrote:
> Rick, you're supposedly familiar with Ruby. And yet, you
> didn't notice that your supposed "fix" didn't touch any
> executable code, all it did was modify the strings being
> printed.

Because the goal was to *UN-OBFUSCATE* the code, not to
provide a solution for the problem _you_ created.

> Because of this "fix", the printed strings no longer match
> the code being executed, but the strange, inconsistent
> behaviour still occurs.

The supposed "inconsistent behavior" here has absolutely
nothing to do with Ruby, no, it's all on _you_. _YOU_ are
the one who created a non-sensical function with a single
char name; and _YOU_ are the one who placed a call to that
function in the middle of an expression, which, on first
glance, looks to be a common numeric addition or string
concatenation. There are no syntactical clues that `a` is a
function. Thus, it is _YOU_ who is to blame for the supposed
"unexpected output".

Ruby followed the rules.

But you didn't.

Like a mad scientist you injected obfuscation into your
source code and then blamed Ruby because your poor naming
conventions and your clumsily formed expressions did not
produce the "purdy little result" you expected.
Congratulations, you have forsaken the most vital principle
of good programming -> Readability Counts!.

"Code is read more often than it is written" (ring a bell?).

No self-respecting professional programmer would ever write
in such a manner. Its the kind of crapola that will get you
fired in 2 seconds. Yet, here you are -- THE GREAT AND
POWERFUL D'APRANO -- thumping your chest over this
horrendous code and acting as if we should be proud of you.

Yip of the day: No one is proud of you.

> Here's the code again:

No thanks. I've seen more than i care to see of your little
"examples".

> Of course we can solve the problem by always using
> parentheses when making function calls.

I'm sorry, but _we_ are not required to solve the problems
_you_ create. _You_ made that mess, and now _you_ can clean it
up.

> But that misses the point that Ruby allows this
> inconsistency in the first place.

Hmm, i see. And if the operator of an automobile purposesly
drives off a cliff, who do you blame: driver or
manufacturer?



More information about the Python-list mailing list