unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: guile-devel@gnu.org
Subject: define-syntax
Date: Tue, 15 Jun 2010 22:48:46 +0200	[thread overview]
Message-ID: <87bpbcm381.fsf@gnu.org> (raw)

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	other threads:[~2010-06-15 20:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-15 20:48 Ludovic Courtès [this message]
2010-06-15 22:06 ` define-syntax Andy Wingo
2010-06-15 22:38   ` define-syntax Ludovic Courtès
2010-06-16  7:35 ` define-syntax Marco Maggi
2010-06-18  8:39   ` define-syntax Andy Wingo
2010-06-18 14:41     ` define-syntax Marco Maggi
  -- strict thread matches above, loose matches on Subject: below --
2008-12-09 16:51 define-syntax Pach Roman (DGS-EC/ESG3)
2008-12-09 20:20 ` define-syntax Neil Jerram
2008-12-09 20:52   ` AW: define-syntax Pach Roman (DGS-EC/ESG3)
2008-12-09 21:17     ` define-syntax Neil Jerram

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bpbcm381.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).