[plt-scheme] How to view the results of macro expansion in Dr Scheme?

From: Grant Rettke (grettke at acm.org)
Date: Thu Oct 18 09:06:31 EDT 2007

On 10/18/07, Robby Findler <robby at cs.uchicago.edu> wrote:
> Probably best to supply a (hopefully small) example.

(require (lib "class.ss"))

(define service-call%
  (class* object% ()
    (property customer-name)
    (property customer-id)
    (property call-type-code)
    (property date-of-call-string)

(define-syntax property
  (lambda (stx)
    (define gen-id ; Source: _TSPL3rdEd_ by Kent Dybvig
      (lambda (template-id . args)
            (lambda (x)
              (if (string? x) x
                  (symbol->string (syntax-object->datum x))))
    (syntax-case stx ()
      [(_ name)
           ([property-name (gen-id (syntax name) "field-" (syntax name))])
            (field (property-name null))
            (define/public (name . args)
              (if (null? args) property-name
                  (set! property-name (car args)))))))])))

Posted on the users mailing list.