guile-user
[Top][All Lists]
Advanced

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

Re: a Q on syntax-rules vs syntax-case


From: Mark H Weaver
Subject: Re: a Q on syntax-rules vs syntax-case
Date: Sun, 08 Feb 2015 20:48:30 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Hi Matt,

Matt Wette <address@hidden> writes:
> I want to use macros inside a let which is part of an expansion of a
> top-level macro in order to have local bindings visible to macros.

Okay, that's fine.

> Is there a difference in implementation (e.g., when inside macros get
> expanded) between using syntax-rules versus syntax-case at the top
> level.

No.  'syntax-rules' is actually just a normal macro that expands into an
equivalent 'syntax-case' form.  Guile's implementation is made more
complex by the presence of features such as docstrings, procedure
metadata, custom ellipses, and R7RS 'syntax-error' support, but if you
strip away those extra features, it looks like this:

  (define-syntax syntax-rules
    (lambda (form)
      (syntax-case form ()
        ((_ (k ...) ((keyword . pattern) template) ...)
         #'(lambda (x)
             (syntax-case x (k ...)
               ((dummy . pattern) #'template)
               ...))))))

> Is this coding considered OK?

Yes, absolutely.  It's fully supported.

  Happy hacking!
      Mark



reply via email to

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