[plt-scheme] Equivalent to prop:procedure for scheme/class?

From: Thomas Chust (chust at web.de)
Date: Sun Feb 28 18:12:51 EST 2010

Hello Dave,

there is a generic way to attach structure properties to interfaces. Try this:

  (define procedure<%>
    (interface* () ([prop:procedure (λ (this . args) (send this apply . args))])
      apply))

  (define my-procedure%
    (class* object% (procedure<%>)

      (super-new)

      (define/public (apply . args)
        (printf "Hello, I'm ~a, and my apply method was called on ~s~%"
                this args))

      ))

  (define procedure
    (new my-procedure%))

  (procedure 1 2 3)

Ciao,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.


Posted on the users mailing list.