But if you do want multimethod dispatch, why immediately starting with a corner case?
This may be a corner case for multi-method dispatch. But this kind of argument pattern matching (and by pattern matching I dont mean reg-exp) is quite common in functional languages, especially in recursive functions. Consider this these list functions in Standard ML, they all have an empty list case;
When pattern matching against arguments in recursive functions like this (and in rescursive multi-method dispatch) it is always good to consider (and explicity code for) your edge cases, otherwise you run the risk of infinite recursion.fun prod [ ] = 1 | prod (h::t) = h * (prod t); fun sum [ ] = 0 | sum (h::t) = h + (sum t); fun length [ ] = 0 | length (h::t) = 1 + (length t);
In reply to Re^2: Hello Perl 6. Running pugs on Windows
by stvn
in thread Hello Perl 6. Running pugs on Windows
by pernod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |