I posted this suggestion earlier in the callable type syntax discussion, at which point it was completely ignored. Possibly because it’s a really stupid idea, but let me post it again on the off chance that it isn’t a stupid idea but was overlooked.
If I can make a wild suggestion: why not create a little language for type specifications?
Indeed.
Using the same syntax may have some benefits for language implementors (e.g. less complex grammar to implement), but I don’t really see these benefits for language users.
As an example, and I don’t know if this has been discussed before, I think a pretty neat syntax construct for optional argument would be (like, for instance, in Kotlin):
def f(x: int? = None): ...
Instead of:
def f(x: Optional[int] = None): …
or
def f(x: int | None = None): …
One could even argue that the “= None” part would be redundant (def f(x: int?): ...) and could be made optional. But that would open another can of worms.
S.