I'm not sure that the example of Julia really serves as an argument for trying curly braces in Python. In Julia, you use curlies both in the class definition and in specializations (e.g. Point{Int}). In Python the latter is already spelled using square brackets (Point[int]). So to follow Julia's example we'd have to use the same brackets in class definitions. And indeed I am not convinced yet that this is a bad plan at all. (However, I don't have a solution for generic type aliases.) On Wed, Jun 1, 2022 at 9:29 PM Steven Troxler <steven.troxler@gmail.com> wrote:
I think Eric's idea of curly braces is worth a close look before we reject it - curly braces handle the ambiguity caused by types being expressions *much* better. ulia uses it [1]; Julia's not a dominant language but it is widely used (largely by people who also use python!) and has syntax that feels pretty python-like, so I think it's a relevant success story for curly brackats.
I do think curly braces look weird at first but my guess is we'd get used to it quickly. I've never heard of it being a big barrier to new users in Julia, whereas I worry that a solution that applies inconsistently to statements vs expressions (like most of the options on the table) might be a permanent tax on users.
There are good arguments *against* curly brackets that didn't apply for Julia, but I'm not convinced by any of them: (1) Julia doesn't have curly-brace-based literals. But there's no ambiguity there since a name can never be directly followed by a literal expression in the existing syntax; I don't think this would be a big problem, especially if by convention there's never a space before the open `{` (2) it might be complicated to work out f-strings rules. I'm not sure about this - I don't entirely understand the *current* rules, because for example (a) f"{g({'a': 5})}" is okay (b) f"{{'a': 5}['a']}" produces `SyntaxError: f-string: single '}' is not allowed` but it seems to me that the current rules could probably be adapted to handle type expressions in roughly the same way
[1] https://docs.julialang.org/en/v1/manual/types/#man-parametric-composite-type... _______________________________________________ Typing-sig mailing list -- typing-sig@python.org To unsubscribe send an email to typing-sig-leave@python.org https://mail.python.org/mailman3/lists/typing-sig.python.org/ Member address: guido@python.org
-- --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-c...>