3 ms·
Python has lambdas so you can still write: foo.fold(lambda successResult: ..., lambda failResult: ...) Even without that, returning a "foo" that has to be
by lmm 9y ago
Python has lambdas so you can still write:
foo.fold(lambda successResult: ..., lambda failResult: ...)
Even without that, returning a "foo" that has to be explicitly unwrapped makes for a safer API than having "foo" be sometimes a valid result and sometimes silently an error instead.
- catnaroek 9y ago> Python has lambdas so you can still write: (snippet) Do you seriously consider this less of a hassle than branching on a frigging bit?
- lmm 9y agoI think single entry/single exit is very valuable, and worth a bit of clunkiness for. And the branch version is also pretty clunky: either the long-winded "return ", abuse of "and"/"or", or the weirdly backwards expression version of "if" that Python has.
- catnaroek 9y agoI don't disagree that branching on bits is clunky. That it's still less clunky than using Church or Scott-encodings speaks volumes of the practicality of the latter.