Library implementation for pattern matching
Idan Arye via Digitalmars-d
digitalmars-d at puremagic.com
Tue Aug 26 12:13:28 PDT 2014
On Monday, 25 August 2014 at 22:35:08 UTC, Dicebot wrote:
> Don't have time to comment in details but wanted to warn about
> one thing : don't over-engineer. There is only limited value in
> a smart utility if its usage pattern can't be immediately
> recognized by a new developer.
Well, what I had in mind is more complex than
`predSwitch`/`castSwitch`/`regexSwitch`, but not *that* complex.
I want to support syntax like:
uint multiplyTuple(Tuple(int, int) operands){
return operands.patternMatch!(
(Constrainted!(uint, "==", 0), uint _) => 0,
(Constrainted!(uint, "==", 1), uint b) => b,
(a, uint b) => b + multiplyTuple(tuple(a - 1, b)),
)();
}
More information about the Digitalmars-d
mailing list