[racket] About genericity...

From: Daniel Prager (daniel.a.prager at gmail.com)
Date: Sat Apr 5 18:21:32 EDT 2014

Hi Roman

> I think, Alejandro wanted to add clauses in different places (generic in
one module, added method in another, for example).

Quite possibly, or perhaps not! ;-)

Alejandro gave an example of one declaration mechanism that he'd seen in
CL. Hard to tell whether that's optimal for his context, or if that's what
he's familiar with.

Dan

On Thu, Apr 3, 2014 at 8:43 PM, Roman Klochkov <kalimehtar at mail.ru> wrote:

> Or even simpler
>
> (define (dup a)
>   (cond
>     [(string? a) (string-append a a)]
>     [(integer? a) (list a a)])
>
> :-)
>
> I think, Alejandro wanted to add clauses in different places (generic in
> one module, added method in another, for example).
>
>
> Thu, 3 Apr 2014 20:11:36 +1100 от Daniel Prager <daniel.a.prager at gmail.com
> >:
>
>   Here's an out-of-the-box option, using Racket's pattern matching<http://docs.racket-lang.org/reference/match.html#%28form._%28%28lib._racket%2Fmatch..rkt%29._define%2Fmatch%29%29> with the
> (? predicate) form:
>
> (define/match (dup a)
>   [((? string?)) (string-append a a)]
>   [((? integer?)) (list a a)])
>
> Dan
>  ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>
>
> --
> Roman Klochkov
>



-- 
*Daniel Prager*
Agile/Lean Coaching, Software Development and Leadership
Startup: www.youpatch.com
Twitter: @agilejitsu <https://twitter.com/agilejitsu>
Blog: agile-jitsu.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140406/5fc274c8/attachment-0001.html>

Posted on the users mailing list.