[plt-scheme] Another newbie programming problem (MzScheme)

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Jun 14 11:15:43 EDT 2002

Would sth like this help? 

(define-syntax (define-class stx)
  (syntax-case stx ()
    [(_ name% [m1 txt] ...)
     (syntax 
      (define name% (class* Object% ()
                      (define/public (m1)
                        (display txt))
                      ... 
                      (super-instantiate ()))))]))

;; Test1
(define-class a% [hello "hello world"])
(define o (make-object a%))
(send o hello)

(newline)

;; Test2
(define-class b% [good "Good"][bye "Bye"])
(define p (make-object b%))
(send p good)
(send p bye)

-- Matthias




Posted on the users mailing list.