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

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Mar 25 18:54:54 EDT 2018


On Sun, 25 Mar 2018 10:33:49 -0700, Rick Johnson wrote:

> On Sunday, March 25, 2018 at 9:11:35 AM UTC-5, Steven D'Aprano wrote:
>> On Sun, 25 Mar 2018 04:49:21 -0700, Rick Johnson wrote:
> [...]
>> I never said anything about not allowing it. But since you've gone on
>> the defence about parens-free function calls, how is this for
>> "consistency" in Ruby?
>>
>> [steve at ando ruby]$ ruby ws-example.rb a + b => 7
>> a+b   => 7
>> a+ b  => 7
>> a +b  => 3
>>
>> Here's the source code:
>>
>> # --- cut ---
>> def a(x=4)
>>     x+2
>> end
>>
>> b = 1
>> print "a + b => ", (a + b), "\n"
>> print "a+b   => ", (a+b), "\n"
>> print "a+ b  => ", (a+ b), "\n"
>> print "a +b  => ", (a +b), "\n"
>> # --- cut ---
> 
> 
> Short of demonstrating that you have knack for writing obfuscated code
> :-), i don't see the point here.

[supposed "fix" to the sample script snipped]


You know Rick, every time I start to think that talking to you like an 
adult might result in a productive and intelligent conversation, you pull 
a stunt like this.

Once I recover from laughing at your inability to read a simple eight 
line Ruby script, and then laughing even harder at your inability to tell 
the difference between a string in Ruby and an actual function call, I 
*might* come back and read the rest of your post.



-- 
Steve




More information about the Python-list mailing list