<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16414" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV>Hi, my code is very wrong! It goes busted in non top level scopes
(eg within let) This I experienced when trying to write syntaxes let-struct-type
and let-struct-var. The reason is shown below. I dont know any method to find
out whether or not two non top level identifiers reference the
same var. Is there? I did not find any such tool in PLT-help.</DIV>
<DIV>Jos</DIV>
<DIV> </DIV>
<DIV>(((((lambda(x)((((((((x x)x)x)x)x)x)x)x))<BR>
(lambda(x)(lambda(y)(x(x y)))))<BR> (lambda(x)(x)x))<BR>
(lambda()(printf "Greetings, Jos~n"))))</DIV>
<DIV> </DIV>
<DIV>(module wrong mzscheme<BR>
<BR> (define-for-syntax var-table ())<BR> <BR> (define-for-syntax
(lookup var)<BR> (let loop ((table var-table))<BR> (and (not
(null? table))<BR> (let ((kar (car
table)))<BR> (or (bound-identifier=? var kar) ;
<=== WRONG</DIV>
<DIV> (module-identifier=? var
kar)<BR> (loop (cdr
table)))))))<BR> <BR> (define-for-syntax (check-table stx tag
var)<BR> (if (lookup var)<BR> (printf "var found: ~a ~a (table
length ~a)~n"<BR> (syntax-object->datum
var)<BR> (syntax-object->datum tag)<BR>
(length var-table))<BR> (begin<BR> (set! var-table
(cons var var-table))<BR> (printf "var added: ~a ~a (table
length ~a)~n"<BR> (syntax-object->datum
var)<BR> (syntax-object->datum
tag)<BR> (length var-table)))))<BR>
<BR> (define-syntax (def stx)<BR> (syntax-case stx ()<BR>
((def tag var val)<BR> (begin<BR>
(check-table stx #'tag #'var)<BR> #'(define var
val)))))<BR> <BR> (define-syntax (ref stx)<BR> (syntax-case stx
()<BR> ((ref tag var)<BR>
(begin<BR> (check-table stx #'tag
#'var)<BR> #'var))))<BR> <BR> (provide def
ref))</DIV>
<DIV> </DIV>
<DIV>(require wrong)</DIV>
<DIV> </DIV>
<DIV>(let ((a -1)) (def 1 a -2) (ref 2 a))<BR>(let ((a -3)) (def 3 a -4) (let ()
(ref 4 a)))</DIV>
<DIV> </DIV>
<DIV>; Produced output<BR>; Welcome to DrScheme, version 369.8-svn9mar2007
[3m].<BR>; Language: Textual (MzScheme, includes R5RS) custom.<BR>; var added: a
1 (table length 1)<BR>; var found: a 2 (table length 1)<BR>; -2<BR>; var added:
a 3 (table length 2)<BR>; var added: a 4 (table length 3) ; added!!!<BR>;
-4<BR>; > <BR>; The reason is that in the context of ref 4 variable 'a' would
bind</DIV>
<DIV>; differently from the context of ref 3.<BR>; This means that in a local
context, the register-lookup fails if a</DIV>
<DIV>; reference is made to a struct-type defined outside this context.</DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=gherson@snet.net href="mailto:gherson@snet.net">George Herson</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=jos.koot@telefonica.net
href="mailto:jos.koot@telefonica.net">jos koot</A> ; <A
title=jensaxel@soegaard.net href="mailto:jensaxel@soegaard.net">Jens Axel
Søgaard</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Cc:</B> <A title=plt-scheme@list.cs.brown.edu
href="mailto:plt-scheme@list.cs.brown.edu">plt-scheme@list.cs.brown.edu</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Monday, March 12, 2007 8:16
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [plt-scheme] Dot-notation
for structure field access</DIV>
<DIV><BR></DIV>thanks for this work. I'm using hash tables at<BR>present
but this code will inform my Scheme if not my<BR>scheme.<BR>...<BR>george
<BR>...</BLOCKQUOTE></BODY></HTML>