Comment

Comment by gonnakillme

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.

parent gonnakillme 13 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton