Hello,

On Sun, 14 Feb 2021 18:36:14 +1100
Steven D'Aprano <st...@pearwood.info> wrote:

> On Thu, Feb 11, 2021 at 09:36:25PM -0800, Guido van Rossum wrote:
> 
> > Agreed. I'd prefer the JavaScript solution, since -> already has a
> > different meaning in Python return *type*. We could use -> to
> > simplify typing.Callable, and => to simplify lambda.  
> 
> Please no! That will lead to constant confusion for people who can't 
> remember which arrow operator to use. Is -> the return type symbol or 
> the return value symbol? I forsee many Stackoverflow questions
> "What's the difference between -> and => ?"
> 
> We've seen Paul mistake => for >= and he's not the only one.

Well, my mistake is based on the fact that I don't spend high-level
neurons on remembering mundane low-level things, like order of
characters if the "greater or equals" operator. Instead, low-level
hands motor function neurons get it right when I type (most of the time
;-)). It's the same as I (and many other people I'm sure) don't
remember phone numbers nowadays - why, if modern phones well remember
them themselves, transfer from one instance to another, etc.

Bottom line: after not too long practice, nobody would confuse ">=" and
"=>", as they're different on their usage context (picked up
subconsciously).

> We already have chosen -> as the return type symbol in annotations, 
> there is no ambiguity with also using it as the return value symbol.

You're mastermind to claim it like that. I for one wasn't sure there's
no grammar-level ambiguity. Perhaps now I can say: if an arrow function
appears in the type annotation position, then well, it's a type. That
should work for the parser algorithm.

But there another problem, on humans' side. For humans, it's very
helpful when different concept look somewhat different. And it's very
helpful to use different arrows for values vs types.

> We could even allow both:
> 
>     (values:List[float], arg=0:int -> Type) -> expression

I for one can't parse that (didn't have a morning coffee, but suspect
there's a typo/thinko). Btw, I'm not sure about function values, but
IMHO, type notation should always use parens for arguments, e.g. "(int)
-> int".

> There are plenty of popular and influential languages that use the 
> single line arrow -> such as Maple, Haskell, Julia, CoffeeScript,
> Erlang and Groovy, to say nothing of numerous lesser known and
> obscure languages.

The question is how many of those language have first-class type
literals, and how many use the same notation for function literals and
type literals. 

[]

-- 
Best regards,
 Paul                          mailto:pmis...@gmail.com
_______________________________________________
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/VN6KKLPVOEQ63S6FGJV2J6YOBDAM6ZIO/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to