At Sun, 4 Mar 2012 20:36:23 -0800,
Helmut Rohrbacher wrote:
> The only thing is, how do you extend these properties to built-in types
> like LIST and VECTOR? I'm guessing that you'd need to wrap them in a
> user-defined type...

You could do that, or you could handle them specially in your generic
function. Using Danny's example:

    (define (doolittle! entity)
      (cond
        [(list? entity)
         (printf "Lists don't speak.")]
        [(prop:speak? entity)
         (printf "~a says: " entity)
         ((prop:speak-ref entity) entity)]
        [else
         (raise-type-error 'speak! "speaking animal" entity)]))


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

Reply via email to