I have a little bit of skepticism about the pattern matching syntax, for
similar reasons to those Larry expresses, and that Steve Dower mentioned on
Discourse.
Basically, I agree matching/destructuring is a powerful idea. But I also
wonder how much genuinely better it is than a library that does not require
a language change. For example, I could create a library to allow this:
m = Matcher(arbitrary_expression)
if m.case("StringNode(s)"):
process_string(m.val)
elif m.case("[a, 5, 6, b]"):
process_two_free_vars(*m.values)
elif m.case("PairNone(a, b)"):
a, b = m.values
process_pair(a, b)
elif m.case("DictNode"):
foo = {key, process_node(child_node) for key, child_node in
m.values.items()}
I don't disagree that the pattern mini-language looks nice as syntax. But
there's nothing about that mini-language that couldn't be put in a library
(with the caveat that patterns would need to be quoted in some way).
--
The dead increasingly dominate and strangle both the living and the
not-yet born. Vampiric capital and undead corporate persons abuse
the lives and control the thoughts of homo faber. Ideas, once born,
become abortifacients against new conceptions.
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/TUXJFRSCW2JOYTU5F6TVGPH6X5SRDJOB/
Code of Conduct: http://python.org/psf/codeofconduct/