[Python-ideas] pattern matching proof-of-concept

Michael Selik michael.selik at gmail.com
Sat May 28 03:22:02 EDT 2016


My original dict unpacking proposal was very short and lacked a motivating
usage. Toy examples made my proposal look unnecessarily verbose and
suggested obvious alternatives with easy current syntax.

Nested/recursive unpacking is much more troublesome, especially when
combined with name-binding. I wrote an example to compare my proposal with
current syntax.

Example usage.
https://github.com/selik/destructure/blob/master/examples/fips.py

Implementation.
https://github.com/selik/destructure/blob/master/destructure.py

The design of my module I'm least happy with is the name-binding. I
extended a SimpleNamespace to create an Erlang-style distinction between
bound and unbound names. Though the API is a bit awkward, now that the
module is built, I'm less enthusiastic about introducing new syntax. Funny
how that works.

I haven't yet decided how to add post-binding guards to the cases.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160528/c0082a6e/attachment.html>


More information about the Python-ideas mailing list