Hi all,
I am trying to follow the incremental approach to compiler construction at
http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf

I am trying to define a macro that will do the following -

(define-primitive (add a b) ....

-> create a hashtable called add-property-table and put in information such
as number of arguments
-> create another macro called add that will expand any occurrence of (add
...) to (list add ...)

As I understand, I would need to define a macro inside the macro. Here's
what I tried -

(define-syntax (define-primitive stx)
  (syntax-case stx ()
    ((_ (primitive-name arg* ...) b b* ...)
     (let ((DS datum->syntax) (SS string->symbol) (SD syntax->datum))
       (with-syntax ((table-name (DS stx (SS (format "~a-property-table"
(SD #'primitive-name))))))
         #'(begin
             (define table-name (make-hash))
             (hash-set! table-name 'is-prime #t)
             (hash-set! table-name 'arg-count (length '(arg* ...)))
             (hash-set! table-name 'emitter (lambda (arg* ...) b b* ...))

             (define-syntax primitive-name
               (syntax-rules ()
                 ((primitive-name a) (list 'primitive-name a))
                 ((primitive-name a b) (list 'primitive-name a b)))) ; I
cant seem to use ... here
             ))))))

To test this, I defined
(define-primitive (add a b c d) (print (+ a b c d)))

(add 1) works fine an returns '(add 1) . However, (add 1 2) does not work
-> bad syntax.

Could someone please tell me how I could get this to work?

Regards,
Kashyap

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to