Hello, On Fri, 13 Nov 2020 21:51:49 +1100 Steven D'Aprano <st...@pearwood.info> wrote:
> > match foo: > > case ("foo", >val1): > > ... > > case ("bar", >val2): > > ... > > > 1. Much more intuitive for beginners. (If Python adopts it, I see > > other "user-friendly" languages adopting the same pattern in the > > coming decades). > > I think you and I have a very different concept of "intuitive for > beginners" here. I don't think that using the *greater than symbol* > as a sigil for assignment would have been "intuitive" to me as a > beginner, or anyone I have helped teach over the years. Treat it as "arrow pointing into a variable identifier, meaning that value is getting into variable". ">>" and "->" are other alternatives with the same intuitive connotation. ">>" is a particularly interesting choice, as it should give warm fuzzy feelings (and partial moral compensation) to all folks who miss the print statement ('print >>sys.stderr, "foo"'). [] > > # Why is this possible? > > obj.foo, obj.bar = val > > > > # And this is not? > > match val: > > case obj.foo, obj.bar: > > > I agree with this. I think it is surprising that unqualified names > are binding patterns but qualified names are not. That difference > gives me pause. But *that's the problem* we're trying to solve! Aka, stop resolving binding-vs-value ambiguity by assigning semantic discrepancies to different *syntactic* patterns, and instead, consider using *punctuation* to resolve the ambiguity. And then there're 2 choices. 1. Use punctuation ("sigils") to mark as-value terms (expressions). This is now well (enough) covered in PEP642, from which this thread is, well, started. 2. Use punctuation ("sigils") to mark as-binding terms. This choice still seems to be under-considered. (As in: it doesn't seem like many people, including the PEP authors, tried to say "indeed, what if?" and feel thru it. I mean, try really hard. I trust the "gang of 4" spent maybe whole few hours on that and delivered "no" to all us. It's still not the same as dozens of people trying it over a few months). > But using `>` as an assignment sigil is surely worse > than the problem you hope to solve with it. ">" is just a notation mark and one of many possible choices. ">", "->", ">>", "@", "$" were mentioned before, and today, even word-fulls like "bind" were proposed (thread "Words rather than sigils in Structural Pattern Matching"). All valid choices to consider, *once* we agree that it is a viable idea to mark bind-terms, on par with other alternatives, and not a throw-away "misconception", how PEP635 tries to represent it (https://www.python.org/dev/peps/pep-0635/#capture-patterns) -- Best regards, Paul mailto:pmis...@gmail.com _______________________________________________ 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/6HNB5JDA4SI2R6PM6KSQ24WYW2CLBEWW/ Code of Conduct: http://python.org/psf/codeofconduct/