[plt-scheme] Inheriting Macro Definition

From: David J. Neu (djneu at att.net)
Date: Thu Feb 24 17:33:45 EST 2005

Hi,

I'm using the PLT class system and I would like to define a macro in a
superclass and have that macro available in a derived class.

The attempt listed below (obviously) doesn't work, and I'm wondering
if there is a solution to this?

Many thanks!

Cheers,
David



(require (lib "class.ss"))

(define xy%
  (class object%
    (init-field (x 1) (y 2) (state '((a . 1) (b . 2) (c . 3))))
     (define-syntax get-state
       (syntax-rules ()
        ((_ variable) (cdr (assq (quote variable) state)))))
    (super-new)
    (printf "~a~n" (get-state b))))

(define xyz%
  (class xy%
    (inherit-field x y state)
    (init-field (z 3))
    (super-new)
    (printf "~a~n" (get-state))))

(define p1 (new xy%))
(define p2 (new xyz%))


mzscheme -M errortrace -r ot.ss
2
2
reference to undefined identifier: get-state
/tmp/ot.ss:18:20: get-state
/tmp/ot.ss:18:19: (get-state)
/tmp/ot.ss:18:4: (printf "~a~n" (get-state))
[unknown source]: (do-make-object xyz% (list) (list))



Posted on the users mailing list.