On Mon, Mar 14, 2022 at 3:05 PM Sebastian Rittau <srittau@rittau.biz> wrote:
Am 14.03.22 um 15:51 schrieb Sergei Lebedev:

> class C[T, S]:
>     def foo[R=int](self) -> R: pass

Could you clarify what the "=int" part stands for?

A type var default (not currently supported by type vars).

 I think it might be easier if the new syntax does not add any new features to type vars, at least initially.
> Some ideas how we could express upper bounds, constraints, and variance: [...]

Wdyt about <= for defining an upper bound and +/- for variance annotations? IIRC both are used at least in Scala and OCaml has +/- for specifying variance and </> for polymorphic variants.

This could work, but I'm not too fond of using too many punctuation characters. Python has always been the antithesis to "line-noise" Perl, and I think "key words" (not necessarily "keywords" from a parser perspective) are more readable and obvious.

Fair enough. C# and Kotlin have nice syntax for variance annotations via in/out keywords. Apart from being more "readable", I also found them to be more instructive when debugging variance-related type errors.  

Sergei