;; Copyright 2008 Ryan Culpepper
;; Released under the terms of the modified BSD license (see the file
;; COPYRIGHT for terms).

(module compat mzscheme
  (require (planet "" ("dyoo" "version-case.plt" 1 4)))
  (require (prefix kw: (lib "")))

  (provide lambda/kw)

   ((version< (version) "3.99")
    ;; Only one keyword protocol
    (define-syntax lambda/kw
      (make-rename-transformer #'kw:lambda/kw)))

    ;; For 3.99:
    ;; Need to support both old and new keyword protocols
    (require (only scheme make-keyword-procedure))
    (define-syntax lambda/kw
      (syntax-rules ()
        [(lambda/kw formals . body)
         (let ([inner-proc (kw:lambda/kw formals . body)])
            (lambda (kws kwargs . rest)
              (apply inner-proc
                     (append (apply append (map list kws kwargs)) rest)))))])))))