[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patch] variable datums with syncase transformer
From: |
Stephen Compall |
Subject: |
[patch] variable datums with syncase transformer |
Date: |
Fri, 14 Dec 2007 02:06:56 -0600 |
Issue most easily explained with a simple reproduction:
guile> (use-syntax (ice-9 syncase))
guile> (@ (guile) car)
ERROR: invalid syntax #<variable b7c50a40 value: #<primitive-procedure car>>
The reasoning of the fix is best described in the long comment in the
patch below. If you would rather that I modify psyntax.ss to use a new
procedure name rather than `self-evaluating?' please let me know. Patch
does not include log entries, listed immediately below instead:
ice-9/ChangeLog:
2007-12-14 Stephen Compall <address@hidden>
* syncase.scm: Support datums where (variable? DATUM) => #t
when syncase transformer is installed.
test-suite/ChangeLog:
2007-12-14 Stephen Compall <address@hidden>
* tests/syncase.test: Test that @-forms can be expanded by
the syncase transformer.
Index: ice-9/syncase.scm
===================================================================
RCS file: /sources/guile/guile/guile-core/ice-9/syncase.scm,v
retrieving revision 1.35
diff -u -d -u -r1.35 syncase.scm
--- ice-9/syncase.scm 16 Apr 2006 23:43:48 -0000 1.35
+++ ice-9/syncase.scm 14 Dec 2007 07:55:49 -0000
@@ -194,6 +194,18 @@
"syncase's gensym expected 0 or 1 arguments, got "
(length rest)))))))))
+;; The question syncase is asking when it asks `self-evaluating?' is
+;; not really whether a given datum is self-evaluating, but whether it
+;; should pass the datum through as-is to the evaluator. With that in
+;; mind, we wrap core `self-evaluating?' here so that syncase will
+;; pass-through variables, meaning (variable? datum) => #t, to the
+;; evaluator. Without this, the system transformer will see a
+;; variable datum as invalid syntax, which it is not to the core
+;; transformer.
+(define (self-evaluating? datum)
+ (or ((@ (guile) self-evaluating?) datum)
+ (variable? datum)))
+
;;; Load the preprocessed code
(let ((old-debug #f)
Index: test-suite/tests/syncase.test
===================================================================
RCS file: /sources/guile/guile/guile-core/test-suite/tests/syncase.test,v
retrieving revision 1.5
diff -u -d -u -r1.5 syncase.test
--- test-suite/tests/syncase.test 16 Apr 2006 23:27:14 -0000 1.5
+++ test-suite/tests/syncase.test 14 Dec 2007 07:55:49 -0000
@@ -34,3 +34,15 @@
(pass-if "basic syncase macro"
(= (plus 1 2 3) (+ 1 2 3)))
+
+(pass-if "variable?s recognized as datums"
+ (false-if-exception
+ (begin (eq? car (eval '(@ (guile) car) (current-module)))
+ #t)))
+
+(define-syntax export-safe-plus
+ (syntax-rules ()
+ ((_ x ...) ((@ (guile) +) x ...))))
+
+(pass-if "variable?s passed through to evaluator"
+ (= (export-safe-plus 1 2 3) (+ 1 2 3)))
--
Our last-ditch plan is to change the forums into a podcast, then send
RSS feeds into the blogosphere so our users can further debate the
legality of mashups amongst this month's 20 'sexiest' gadgets.
--Richard "Lowtax" Kyanka
signature.asc
Description: This is a digitally signed message part
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [patch] variable datums with syncase transformer,
Stephen Compall <=