guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

define-syntax


From: Ludovic Courtès
Subject: define-syntax
Date: Tue, 15 Jun 2010 22:48:46 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Hello,

>From R6RS Section 10:

  define-syntax form  The expander expands and evaluates the
    right-hand-side expression and binds the keyword to the resulting
    transformer.

Thus I think the following should work:

  (define-syntax +
    (let ((plus +))  ;; `+' should resolve to whatever `+' is bound to
                     ;; before this definition
      (lambda (stx)
        (syntax-case stx ()
          ((_ args ...)
           (apply plus (map syntax->datum #'(args ...))))))))

But it fails when expanding the macro:

  scheme@(guile-user)> (+ 2 3)
  Throw to key `wrong-type-arg':
  ERROR: In procedure vm-debug-engine:
  ERROR: Wrong type to apply: #<syntax-transformer +>

Thoughts?

Thanks,
Ludo’.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]