On Tue, Jun 09, 2020 at 05:06:37PM -0700, Guido van Rossum wrote:

> But wait, there's more! The same syntax will make it possible to call *any*
> function:
> 
> >>> len "abc"
> 3

As you point out later on, there are issues with zero-argument calls and 
calls where the first argument starts with parens.

Ruby allows parens-less function calls. Run this in Ruby and weep:

    #!/usr/bin/ruby
    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"


For those who don't have Ruby installed, here is the output:

    a + b => 7
    a+b   => 7
    a+ b  => 7
    a +b  => 3

In case it's not obvious, the problem isn't the call to print, but the 
call to function `a`. (Tested in Ruby 2.5).

There's also yet another precedence rule to learn:

    sqrt x + 1

means what?

Given Python's execution model where we have statements and functions, I 
think that it is a feature that they have different syntax. If I see 
words separated by spaces:

    import math
    del spam
    while condition
    if obj
    assert condition

I know that they are special syntactic forms, even if I'm reading code 
using some new statement I had missed learning about:

    # Python 7 code, fallen through a wormhole
    require thing
    demand permission
    spam contacts
    verb object

I don't think we should give up that nice clean distinction between 
function calls which always require parens, and statements which don't 
require parens, merely to add a second way to call functions that saves 
one char:

    func(x)
    func x
    
I'd be more interested in the idea if there was more benefit than just 
the avoidance of a pair of parens. Something that either can't be done 
at all, or can only be done with difficulty. Something like IPython's 
%magic syntax perhaps?



-- 
Steven
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/WG3NCEQX7CIEEGHHWJQFLOWVBJ7UQQC6/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to