bug-guile
[Top][All Lists]
Advanced

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

(ice-9 syncase) doesnt't expand identifiers


From: Martin Wilck
Subject: (ice-9 syncase) doesnt't expand identifiers
Date: Wed, 11 Oct 2000 16:57:02 +0200

Hi,

I think there is a bug in the (ice-9 syncase) module.

According to Dybvig, The Scheme Programming Language, 2nd ed. 1996,
macros can occur and be expanded anywhere (not only in the leading 
"procedure" position of an expression).

guile> (define-syntax simple 
            (lambda (x)
               (syntax-case x () (_ (identifier? x) 0))))

guile> simple                       ;;  => 0  (according to Dybvig)
#<macro 401c4a10>

guile> (eval 'simple)             ;; !!!
0

guile> (macro? simple)
#t

The problem seems to be that the REPL's definition of `eval' isn't changed
by loading the syncase module.

The explicit call to eval, on the other hand, has been redefined by a
define-public statement in syncase.scm.

The appended simple patch (against guile version 1.4) works for me.
I have no idea whether it's dangerous to change the root definition
of `eval', but so far I've not experienced any problems except that 
guiles macro functions (such as `macro?') don't work on macros 
created with define-syntax:

[patched version]

guile> (define-syntax simple 
  (lambda (x)
    (syntax-case x () (_ (identifier? x) 0))))
guile> simple
0
guile> (macro? simple)
#f

However, I think this is less important than the fact that
without this patch not only this trivial example, but many
advanced applications of syntax-case will only
work by calling `eval' explicitly.

Best regards, 
Martin

PS If you consider applying this patch (or some variation of it), don't worry
     about copyright - I'm already registered with the FSF.

PS(2) I am not currently subscribed to the guile mailing lists.

Martin Wilck <address@hidden> 
Inst. for Tropospheric Research, Permoserstr. 15, 04303 Leipzig, Germany

-- --- syncase-orig.scm Wed Oct 11 16:51:46 2000
+++ syncase.scm Wed Oct 11 16:55:32 2000
@@ -150,13 +150,14 @@
 ;;; The following line is necessary only if we start making changes
 ;; (load-from-path "ice-9/psyntax.ss")
 
-(define internal-eval (nested-ref the-scm-module '(app modules guile eval)))
-
-(define-public (eval x)
-  (internal-eval (if (and (pair? x)
-                         (string=? (car x) "noexpand"))
-                    (cadr x)
-                    (sc-expand x))))
+(module-set! the-root-module 'eval
+            (let ((internal-eval 
+                   (nested-ref the-scm-module '(app modules guile eval))))
+              (lambda (x)
+                (internal-eval (if (and (pair? x)
+                                        (string=? (car x) "noexpand"))
+                                   (cadr x)
+                                   (sc-expand x))))))
 
 ;;; Hack to make syncase macros work in the slib module
 (let ((m (nested-ref the-root-module '(app modules ice-9 slib))))




reply via email to

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