On Sun, 3 Jan 2021 at 23:38, Nick Coghlan <ncoghlan@gmail.com> wrote:
The instance attribute syntax arose from trying to deal with two problems from class patterns in PEP 634:
* "ATTR=TARGET" using "=" to bind to the right instead of to the left * no subsequent path to ever offering a syntax for *retrieving* multiple attributes in ordinary expressions outside pattern matching
The minimal fix for the first point would have been just "case object(host=as host, port=as port}:", but that couldn't ever be used to retrieve multiple attributes, as "object(host, port)" is already a function call.
OK, so there's our dispute. Neither of those seem to me to be problems with PEP 634. 1. I view ATTR=PLACEHOLDER as *equality* with a placeholder that gets filled in, not a binding that goes left to right. (And no, I don't have a problem with the rule that the placeholder must be on the right). 2. I don't see any immediate reason to assume we want to "retrieve multiple attributes in ordinary expressions". We can easily add a "match let" statement that did match-style destructuring, why do we need it to be built in to ordinary assignment (which is what I assume you mean)? So IMO you're producing a weird syntax to solve problems I don't believe exist in the first place. Whereas PEP 634 offers a feature that I think I would find useful, using a syntax that I find perfectly comfortable in the context in which it's defined. Paul