unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [patch] variable datums with syncase transformer
@ 2007-12-14  8:06 Stephen Compall
  2008-03-05 14:59 ` Ludovic Courtès
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Stephen Compall @ 2007-12-14  8:06 UTC (permalink / raw)
  To: guile-devel


[-- Attachment #1.1: Type: text/plain, Size: 3010 bytes --]

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  <s11@member.fsf.org>

	* syncase.scm: Support datums where (variable? DATUM) => #t
	when syncase transformer is installed.

test-suite/ChangeLog:

2007-12-14  Stephen Compall  <s11@member.fsf.org>

	* 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

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel

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

end of thread, other threads:[~2008-03-06 23:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-14  8:06 [patch] variable datums with syncase transformer Stephen Compall
2008-03-05 14:59 ` Ludovic Courtès
2008-03-05 15:36   ` Stephen Compall
2008-03-05 16:34 ` Ludovic Courtès
2008-03-05 20:55   ` Neil Jerram
2008-03-05 22:16     ` Stephen Compall
2008-03-05 23:21     ` Ludovic Courtès
2008-03-06 23:28 ` Neil Jerram

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