chicken-hackers
[Top][All Lists]
Advanced

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

Re: [Chicken-hackers] [PATCH] handle aliases generated by macro-expansio


From: Felix
Subject: Re: [Chicken-hackers] [PATCH] handle aliases generated by macro-expansion in "declare"
Date: Fri, 21 Oct 2011 13:35:13 +0200 (CEST)

From: Felix <address@hidden>
Subject: Re: [Chicken-hackers] [PATCH] handle aliases generated by 
macro-expansion in "declare"
Date: Fri, 21 Oct 2011 13:23:10 +0200 (CEST)

> From: Peter Bex <address@hidden>
> Subject: Re: [Chicken-hackers] [PATCH] handle aliases generated by 
> macro-expansion in "declare"
> Date: Fri, 21 Oct 2011 09:00:36 +0200
> 
>> On Fri, Oct 21, 2011 at 03:33:03AM +0200, Felix wrote:
>>> > The attached patch resolves macro-aliases correctly when resolving
>>> > identifier names in "declare" forms. Without this, identifiers that
>>> > went through several macro-expansions (and thus aliasing) where not
>>> > resolved to their true names, yielding declarations ineffective.
>>> 
>>> That patch was broken. Please use this one instead.
>> 
>> Won't this loop forever when sym refers to a macro?
>> In this case, it calls loop1 with sym again, which
>> probably means it'll keep going.
> 
> Hm. Right. I'll produce another patch.
> 

Here it is. Thanks for pointing out the problem with the old
patch.


cheers,
felix
>From 8def51277836b3a4daa4ed48a1c4b4fab496b0f6 Mon Sep 17 00:00:00 2001
From: felix <address@hidden>
Date: Fri, 21 Oct 2011 02:52:53 +0200
Subject: [PATCH] handle macro-aliases when resolving declared identifier, making
 sure things are done right inside modules.

---
 expand.scm |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/expand.scm b/expand.scm
index 87cd8a2..74adbc8 100644
--- a/expand.scm
+++ b/expand.scm
@@ -136,13 +136,16 @@
 ;;; resolve symbol to global name
 
 (define (##sys#globalize sym se)
-  (if (symbol? sym)
-      (let loop ((se se))                      ; ignores syntax bindings
-       (cond ((null? se)
-              (##sys#alias-global-hook sym #f #f)) ;XXX could hint at decl 
(3rd arg)
-             ((and (eq? sym (caar se)) (symbol? (cdar se))) (cdar se))
-             (else (loop (cdr se)))))
-      sym))
+  (let loop1 ((sym sym))
+    (cond ((not (symbol? sym)) sym)
+         ((getp sym '##core#macro-alias) => 
+          (lambda (a) (if (symbol? a) (loop1 a) sym)))
+         (else
+          (let loop ((se se))          ; ignores syntax bindings
+            (cond ((null? se)
+                   (##sys#alias-global-hook sym #t #f)) ;XXX could hint at 
decl (3rd arg)
+                  ((and (eq? sym (caar se)) (symbol? (cdar se))) (cdar se))
+                  (else (loop (cdr se)))))))))
 
 
 ;;; Macro handling
-- 
1.7.0.4


reply via email to

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