I've ported little collection for making CLOS-like generics  
https://github.com/Kalimehtar/gls

It gives you possibility to make generics over any predicates or racket/class 
classes:

Example (impossible in swindle):

(define (fact x)
  (defgeneric fact0
    (method ((n (and? <integer> (<=/c 1))) (acc <integer>))
            acc)
    (method ((n <integer>) (acc <integer>))
            (fact0 (- n 1) (* acc n))))
  (fact0 x 1))

You may add methods dynamically:
(defgeneric g)
(add-method g (method ((x frame%)) (do-something-with-frame x ...)))
(add-method g (method ((x button%)) (do-something-with-button x ...)))

More examples in  https://github.com/Kalimehtar/gls/blob/master/gls/test.rkt

P. S. Can't add it to pkg.racket-lang.org. Press "login" then "Log in", but no 
email. :-(

-- 
Roman Klochkov
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to