expanded keyword paremeter without default value doesn't refer proper variable.

Create issue
Issue #16 resolved
Takashi Kato repo owner created an issue

The following script should print keyword and value pair and return ok but got unbound variable error.

(import (rnrs))

(define-syntax define-key
  (lambda (x)
    (define (key&name sym) (list (make-keyword sym) sym))
    (define (params slots)
      (let loop ((slots slots) (r '()))
    (syntax-case slots ()
      (() (reverse! r))
      ((name . rest)
       (loop (cdr slots) (cons (key&name (syntax->datum #'name)) r))))))
    (syntax-case x ()
      ((k name (p ...) body ...)
       (with-syntax ((((keys names) ...) 
              (datum->syntax #'k (params #'(p ...)))))
     #'(define (name :key names ...)
         (print (apply append! (list `(keys ,names) ...)))
         body ...))))))

(define-key test (a b c) 'ok)

Comments (2)

  1. Log in to comment