Using "&" to combine different annotations (replacement for typing.Annotated)
Hello, Some time ago we discussed with Steven D'Aprano how "const" annotation would be combined with other annotations: https://mail.python.org/archives/list/python-dev@python.org/message/SQTOWJ6U... I mentioned that while current way is to use `typing.Annotated`: spam: Annotated[Widget, const] = build_widget(*args) , it looks ugly, and we can shoot for better. I proposed to use "&" to combine annotations: spam: Widget & const = build_widget(*args) Today I came by another new proglingo, https://flix.dev/ , which uses Python-ish syntax and just very this idea, e.g.: /// We can also declare an impure function. def printAndInc(x: Int): Int & Impure = Console.printLine("Hello"); x + 1 It's always helpful to look at some idea "from outside". And well, I'm sold on it! (As if I wasn't before.) -- Best regards, Paul mailto:pmiscml@gmail.com
participants (1)
-
Paul Sokolovsky