unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Patch to add (define-syntax (foo bar) ...) support
@ 2011-07-03 20:19 Chris K. Jester-Young
  2011-07-03 20:44 ` Noah Lavine
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Chris K. Jester-Young @ 2011-07-03 20:19 UTC (permalink / raw)
  To: guile-devel

[-- Attachment #1: Type: text/plain, Size: 655 bytes --]

Hi there,

When writing syntax-case macros, often one would write:

    (define-syntax foo
      (lambda (bar)
        (syntax-case bar ...)))

This seems overly long-winded; it would be preferable to be able to
write, instead:

    (define-syntax (foo bar)
      (syntax-case bar ...))

Attached is a patch that implements that. Note that there is nothing
original in this patch---it's just a straight copy-and-paste of the
"define" version immediately above, except changing define-form to
define-syntax-form---so there should be nothing controversial from a
correctness and/or copyright point of view.

Let me know what you think.

Many thanks,
Chris.

[-- Attachment #2: psyntax.scm.diff --]
[-- Type: text/x-diff, Size: 1012 bytes --]

diff --git a/module/ice-9/psyntax.scm b/module/ice-9/psyntax.scm
index 957a526..e83b3ff 100644
--- a/module/ice-9/psyntax.scm
+++ b/module/ice-9/psyntax.scm
@@ -1168,7 +1168,16 @@
                      ((_ name val)
                       (id? #'name)
                       (values 'define-syntax-form #'name
-                              #'val w s mod))))
+                              #'val w s mod))
+                     ((_ (name . args) e1 e2 ...)
+                      (and (id? #'name)
+                           (valid-bound-ids? (lambda-var-list #'args)))
+                      ;; need lambda here...
+                      (values 'define-syntax-form (wrap #'name w mod)
+                              (decorate-source
+                               (cons #'lambda (wrap #'(args e1 e2 ...) w mod))
+                               s)
+                              empty-wrap s mod))))
                   (else
                    (values 'call #f e w s mod)))))))
          ((syntax-object? e)

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-09-05  7:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-03 20:19 Patch to add (define-syntax (foo bar) ...) support Chris K. Jester-Young
2011-07-03 20:44 ` Noah Lavine
2011-07-03 21:03   ` Chris K. Jester-Young
2011-07-03 21:08     ` Noah Lavine
2011-07-03 22:34 ` Ian Price
2011-09-02  8:32 ` Andy Wingo
2011-09-02 13:33   ` Ian Price
2011-09-02 16:53     ` Andy Wingo
2011-09-05  7:58     ` Marijn

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).