I am trying to make a macro that helps with creating class-like closures. #lang racket (require (for-syntax syntax/parse))
(define-syntax (define/method stx) (syntax-parse stx [(_ (name arg ...) body) #'(begin (define (name arg ...) body) (set! method-list (cons `(name ,name) method-list)))])) (define (make-person name age) (define (obj arg) (define method-list '()) (define/method (get-name) name) (second (assq arg method-list))) obj) The goal is for all occurrences of (define/method ...) to get replaced with a normal define and a key and value added to an existing list. However, racket complains in the macro definition that method-list isn't defined. I thought that macros just replaced code with other code, not evaluated the syntax object that should replace something. (define/method (get-name) name) -> (define (get-name) name) (set! method-list (cons `(get-name ,get-name) method-list)) -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.