[racket] 'Adult' Racket? (was rackunit vs test-engine)

From: Danny Yoo (dyoo at hashcollision.org)
Date: Thu Aug 9 10:37:41 EDT 2012

> Using `racket/generic' (new in 5.3!):
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> #lang racket
>
> (require racket/generic)
>
> (define-generics pokeable
>   [poke! pokeable])
>
> (struct mascot ()
>   #:methods gen:pokeable
>   [(define (poke! self) (printf "Ho ho!\n"))])
>
> (define pillsbury-dough-boy (mascot))
> (poke! pillsbury-dough-boy)
>
> (struct cartoon-character (name)
>   #:methods gen:pokeable
>   [(define (poke! self)
>      (printf "~a: that tickles!\n" (cartoon-character-name self)))])
>
> (define homer (cartoon-character "Homer"))
> (poke! homer)


Oooh.  I like!  I'll definitely look into racket/generics.

Posted on the users mailing list.