On Fri, Jul 10, 2020, 9:16 AM Eric Nieuwland <eric.nieuwland@gmail.com> wrote:

On 10 Jul 2020, at 01:51, Jim Baker <jim.baker@python.org> wrote:
...
Explicit namespacing (if a constant) or using a guard (if a variable) seems to be the right solution, as Ethan demonstrated earlier. No need for . or ^ or  \ or ... to disambiguate. Also it seems to me that structural pattern matching will build on two common usages of namespaces for constants:

1. Constants used from other modules are almost always used in the module namespace. Eg, socket.AF_UNIX or signal.SIGTERM.
2. New code often tends to use constants defined within an Enum namespace. Hopefully we will see more of this convention in usage.

(Very much an aside: Interestingly with the socket module we see both used - it defines its constants with IntEnum and exports them traditionally. The namespace specifics it uses with IntEnum._convert_ to make this happen  -- strictly speaking EnumMeta._convert, not documented, and a bit hard to follow -- might be possibly debatable, but it works out quite well in practice in providing backwards compatibility while continuing to work with a C source of these constants.)
 
This would also mean
        case Point(x=\x, y=\y):
should be used to obtain x and y from the Point instance.

This approach makes deeper nesting of the structure much more cumbersome, I think.

How to match Polygon(Point(x0,y0), Point(x1, y1), Point(x2, y2)) based on its structure?
And Polygon(Point(x0,y0), p1, Point(x2, y2))?


 I'm just trying to describe what v2 of the PEP is trying to do and how it then corresponds to a reasonable usage model. Sorry for any confusion.
 
So in your scenario above, Polygon and Point are used as class patterns (https://www.python.org/dev/peps/pep-0622/#class-patterns). Consequently they are treated accordingly and have that nice structural pattern matching quality!

Earlier I was discussing constant patterns (https://www.python.org/dev/peps/pep-0622/#constant-value-patterns), which require they be namespaced in some way (a qualified name as it is described in the PEP).

- Jim