unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Stephen Compall <s11@member.fsf.org>
To: guile-devel@gnu.org
Subject: [patch] variable datums with syncase transformer
Date: Fri, 14 Dec 2007 02:06:56 -0600	[thread overview]
Message-ID: <1197619616.5218.34.camel@nocandy.dyndns.org> (raw)


[-- 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

             reply	other threads:[~2007-12-14  8:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-14  8:06 Stephen Compall [this message]
2008-03-05 14:59 ` [patch] variable datums with syncase transformer 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

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=1197619616.5218.34.camel@nocandy.dyndns.org \
    --to=s11@member.fsf.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).