Re:What’s New In Python 3.4
by shoo on Sunday October 20, 2013 @05:38PM
(#6581626)
if python were to have algebraic data types, it might also need pattern matching.
[ Parent
| on HN ]
Re:What’s New In Python 3.4
by gonnakillme on Sunday October 20, 2013 @07:40PM
(#6582101)
I don't think pattern matching is necessary for ADTs. It's useful, but you could have e.g.
> if MyType.ConstructorA(a):
> ...
> elif MyType.ConstructorB(a):
> ...
or even something like
> with MyType.ConstructorA(a) as b, c:
> ...
> else with MyType.ConstructB(a) as d:
> ...
a "with/else with" construct would be a fairly straightforward addition to Python's "context manager" interface.
Yes, for better of worse Python is nowadays fairly conservative in introducing backward-incompatible syntax changes, and pattern matching would probably require quite a bit of new syntax (and benefits a lot from a strong compiler).