|
|
Log in / Subscribe / Register

"Structural pattern matching" for Python, part 1

"Structural pattern matching" for Python, part 1

Posted Aug 26, 2020 22:47 UTC (Wed) by mcortese (guest, #52099)
Parent article: "Structural pattern matching" for Python, part 1

I wonder why two such separate concepts as destructuring and case switching must go hand in hand.

I think destructuring ought to have its own syntax, something like

match point into (x, y)
which should return true or false whether the match succeeds or not. It's up to you to use it inside a if clause.

Totally orthogonal to this is the desire to provide a nice way to express a choice between several cases, similar to C's switch statement.

The two will often be used together, but needn't to.


to post comments


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds