Hm, I was specifically thinking of things that introduce new keywords. For
example, TypeScript adds unary operators 'infer' and 'keyof'. It would be
rather difficult to have to define those as soft keywords throughout the
language. (We couldn't just make them unary keywords, since 'infer (x)'
should continue to call the function 'infer', for example. In an annotation
context that might not be a problem, since function calls in general aren't
valid types.)

IIRC Jukka also already brought up the possibility of using something like
'(int) => str' instead of 'Callable[[int], str]' -- but it would be
unpleasant if that syntax had a meaning like you propose outside
annotations.

On Sat, Apr 17, 2021 at 7:12 PM Nick Coghlan <ncogh...@gmail.com> wrote:

>
>
> On Mon, 12 Apr 2021, 1:48 pm Guido van Rossum, <gu...@python.org> wrote:
>
>>
>> At the very least I recommend that the SC take this into account when
>> they consider PEP 649. Accepting it has some nice benefits when it comes to
>> the scoping rules for annotations -- but it would forever close the door
>> for the "relaxed annotation syntax" idea you brought up. (Isn't it fun to
>> be on the SC. :-)
>>
>
> I may have missed someone else mentioning this, but I don't think this
> concern is necessarily true, as even if PEP 649 were accepted, the only
> pre-PEP-563 constraints it would reintroduce would be that all future type
> annotation syntax:
>
> * have a defined runtime effect;
> * that runtime effect be consistent with normal expressions when reusing
> existing syntax; and
> * be explicitly quoted when using type hinting syntax from later Python
> versions in code that needs to run on earlier versions
>
> Any PEPs adding new type hinting specific syntax would be free to define
> the runtime effect of the new syntax as "produces a string containing the
> text of the part of the annotation using the new syntax, as if the new
> syntax were explicitly quoted", even if we decided not to go ahead with the
> idea of applying those "produces a string" semantics to *all* annotations.
>
> Cheers,
> Nick.
>
>
>>
>>

-- 
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him **(why is my pronoun here?)*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/6MY3UBK2J5G2WTKYEG7IWPLLCEVJMIGT/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to