Hi Python-dev and PEP 622 Authors,

I saw this idea, or something like it, posted by a couple of people, but didn't see much discussion of it, and skimming the PEP today, I didn't see a mention of it. Maybe I just missed it; my apologies if so, and a link to the relevant discussion/text would be appreciated.

In any case, the basic idea was to have an explicit namespace that captures are put into, and is treated as assignment instead of lookup. e.g.

match get_point() into m:
  case Point(m.x, m.y):
    print(m.x, m.y)

A variation I saw was "as" instead of "into"; the particular token is bikeshedding. The core idea is an explicit name that is "special" within the match's case expressions.

Personally, I thought this was a rather elegant solution to the load-vs-store problem for names. This is because, essentially, it changes the mental model from "some non-dotted names are special, some aren't, keep a careful eye out" to "only "m." is special, everything else is regular".

I haven't thought about this too deeply (analysis tools might benefit, too?); I wanted to keep this initial email short before investing time/energy/thought into it in case it had already been discussed and discarded.