[plt-scheme] Check syntax and macros

From: Jens Axel Soegaard (jensaxel at soegaard.net)
Date: Thu Oct 18 09:35:46 EDT 2007

Grant Rettke skrev:
> On 10/18/07, Jens Axel Soegaard <jensaxel at soegaard.net> wrote:
>> Which arrows were you expecting to appear after hitting
>> CheckSyntax on the above?
> 
> I was expecting that the "step" buttons would get enabled and that I
> could see the result of the macro expansion for the sample class.

Okay, I thought this thread was about:

     > When I run check syntax in DrScheme, the references don't get
     > pointed out by the arrows.


Anyways, try the program below instead:

Then

  - Hit the "Macro Stepper" button
  - Hit "Next Term" twice
  - Now use "Step"


(require (lib "class.ss"))

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

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


-- 
Jens Axel Søgaard



Posted on the users mailing list.