On Wed, Dec 01, 2021 at 12:26:33PM +0000, Matt del Valle wrote:

> Steven gave the following example of a function signature that would be
> difficult to visually parse if this proposal and arrow lambdas were
> accepted:
> 
> def process(func:List->int=>xs=>expression)->int:
> 
> And while I agree that it does sort of stop you in your tracks when you see
> this, I think there are a couple of reasons why this is not as big of a
> problem as it appears.

I totally agree with you that, for even moderately experienced 
Pythonistas, it is possible to parse that. It's not literally ambiguous 
syntax that cannot be resolved. I am confident that the parser will be 
able to work it out just fine :-)

I care more about the poor reader who may not be a moderately 
experienced Pythonista, and will be trying to work out why there are two 
different arrow symbols with four different meanings:

* function return annotation
* typing.Callable type annotation
* lambda alternative syntax
* late-bound defaults

I'm sure that people will learn the many uses of the arrow symbols. 
After all, people learn Perl and APL :-) Closer to home, we also learn 
all the many different uses of the star symbol `*`.

Yes, spaces will help the reader *parse* the pieces of the function 
signature. But spaces doesn't help the reader decipher and remember the 
different meanings of the arrows. Also the use of extra spaces goes 
against the usual style guides that we *don't* use spaces between the 
colon and the annotation, or the equals sign and the default.

For the sake of discussion, I've been using Chris' arrow symbol, but 
that doesn't mean I've warmed to it. Aside from the other issues, it is 
the wrong way around:

    parameter => expression

implies moving the parameter into the expression, which is the 
wrong way around. The expression moves into the parameter.

E.g. in R, you can write assignment with an equals sign, or an arrow, 
but the arrow points from the value to the variable:

    > x <- 1 
    > 2 -> y
    > c(x, y) 
    [1] 1 2

I've never seen a language or pseudo-code that does assignment with the 
arrow pointing from the variable to the value. Does anyone know of any?



-- 
Steve
_______________________________________________
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/4HPJMGJ4YYQVGHK5IRVSWLUCS2W67GBL/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to