<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Oct 24, 2014, at 6:11 AM, Joan Arnaldich <<a href="mailto:jarnaldich@gmail.com">jarnaldich@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi there,<br><br>I stumbled upon this thread when searching for generics. I really like <br>Alexander's solution, but if I understand it correctly, the my-match-lambda-<br>append function should read something like:<br><br>(define my-match-lambda-append<br>  (case-lambda<br>    [() (case-lambda)]<br>    [(f1 . f2) (lambda args<br>               (with-handlers ([exn:fail:my-match-lambda:no-match:next-<br>clause?<br>                                (λ (e) (apply (apply my-match-lambda-append  <br>f2) args))])<br>                 (parameterize ([within-my-match-lambda-append? #t])<br>                   (apply f1 args))))]))<br><br><br>Notice the dot clause and the recursive call. Otherwise it wouldn't work <br>with more than 2 clauses... <br></blockquote><div><br></div><div>I actually changed this later to do something sort of similar to work with more than 2 clauses (and handle keywords):</div><div><a href="https://github.com/AlexKnauth/hash-lambda/blob/master/mutable-match-lambda/mutable-match-lambda-procedure.rkt#L46">https://github.com/AlexKnauth/hash-lambda/blob/master/mutable-match-lambda/mutable-match-lambda-procedure.rkt#L46</a></div><div><br></div><div><font face="Courier New">(define mutable-match-lambda-clause-append<br>  (case-lambda<br>    [() (case-lambda)]<br>    [(f) f]<br>    [(f1 f2) (keyword-lambda (kws kw-args . args)<br>               (with-handlers ([exn:fail:mutable-match-lambda:no-match:next-clause?<br>                                (λ (e) (keyword-apply f2 kws kw-args args))])<br>                 (parameterize ([within-mutable-match-lambda-clause-append? #t])<br>                   (keyword-apply f1 kws kw-args args))))]<br>    [(f1 . rst) (mutable-match-lambda-clause-append f1 (apply mutable-match-lambda-clause-append rst))]<br>    ))</font></div><div><br></div><div>By the way I'm thinking of rewriting the whole thing further to use something a bit more like this idea (if I can):</div><div><a href="http://www.greghendershott.com/2013/06/a-case-with-fall-through.html">http://www.greghendershott.com/2013/06/a-case-with-fall-through.html</a></div><br><blockquote type="cite"><br>Just for completeness, I created a gist with the full code and updated tests: <br><a href="https://gist.github.com/jarnaldich/056a5856d3b1ce05c312#file-my-match-lambda-">https://gist.github.com/jarnaldich/056a5856d3b1ce05c312#file-my-match-lambda-</a><br>rkt<br><br>Cheers,<br><br>Joan<br><br>____________________<br>  Racket Users list:<br>  http://lists.racket-lang.org/users<br></blockquote></div><br></body></html>