gvanrossum / patma

Pattern Matching
1.02k stars 64 forks source link

Do walruses only bind on a successful match? #43

Open brandtbucher opened 4 years ago

brandtbucher commented 4 years ago

I've just added named pattern (x := <pattern>) support to the reference implementation.

While working on this, I realized that the PEP is a bit vague. Should we always bind the value to x, or only on a successful match? I believe the intent is to bind only on success (and this is how it's implemented), but I wonder if others disagree.

gvanrossum commented 4 years ago

Definitely only on a successful match. Just fix the PEP!

brandtbucher commented 4 years ago

I've updated the PEP.