[plt-scheme] Inheriting Macro Definition

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Thu Feb 24 17:44:00 EST 2005

This looks like a method. Don't use macros fro that. -- Matthias



On Feb 24, 2005, at 5:33 PM, David J. Neu wrote:

>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> 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.