<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Never mind, this (with the syntax-properties) works perfectly: (so far)</div><div><br></div><div><div><font face="Courier New">#lang racket</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(begin-for-syntax</font></div><div><font face="Courier New">  (define hash-1 (make-hash))</font></div><div><font face="Courier New">  (define hash-2 (make-hash))</font></div><div><font face="Courier New">  </font></div><div><font face="Courier New">  (define (with-binding stx #:id id #:hash hash)</font></div><div><font face="Courier New">    (let* ([sym (syntax-e id)]</font></div><div><font face="Courier New">           [id.length (string-length (symbol->string sym))]</font></div><div><font face="Courier New">           [hash-sym (hash-ref! hash sym (gensym sym))]</font></div><div><font face="Courier New">           [new-id (syntax-property (syntax-local-introduce (datum->syntax id hash-sym id id)) 'original-for-check-syntax #t)])</font></div><div><font face="Courier New">      (syntax-property stx</font></div><div><font face="Courier New">                       'sub-range-binders</font></div><div><font face="Courier New">                       (list (vector new-id 0 id.length new-id 0 id.length)))))</font></div><div><font face="Courier New">  </font></div><div><font face="Courier New">  (define (with-ref stx #:id id #:hash hash)</font></div><div><font face="Courier New">    (let* ([sym (syntax-e id)]</font></div><div><font face="Courier New">           [hash-sym (hash-ref! hash sym (gensym sym))]</font></div><div><font face="Courier New">           [ref-id (syntax-property (syntax-local-introduce (datum->syntax id hash-sym id id)) 'original-for-check-syntax #t)])</font></div><div><font face="Courier New">      (syntax-property stx</font></div><div><font face="Courier New">                       'disappeared-use</font></div><div><font face="Courier New">                       (list ref-id))))</font></div><div><font face="Courier New">  )</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(define-syntax (bind-1 stx)</font></div><div><font face="Courier New">  (syntax-case stx ()</font></div><div><font face="Courier New">    [(bind-1 id)</font></div><div><font face="Courier New">     (with-binding #'(void) #:id #'id #:hash hash-1)]))</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(define-syntax (bind-2 stx)</font></div><div><font face="Courier New">  (syntax-case stx ()</font></div><div><font face="Courier New">    [(bind-2 id)</font></div><div><font face="Courier New">     (with-binding #'(void) #:id #'id #:hash hash-2)]))</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(define-syntax (ref-1 stx)</font></div><div><font face="Courier New">  (syntax-case stx ()</font></div><div><font face="Courier New">    [(ref-1 id)</font></div><div><font face="Courier New">     (with-ref #'(void) #:id #'id #:hash hash-1)]))</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(define-syntax (ref-2 stx)</font></div><div><font face="Courier New">  (syntax-case stx ()</font></div><div><font face="Courier New">    [(ref-2 id)</font></div><div><font face="Courier New">     (with-ref #'(void) #:id #'id #:hash hash-2)]))</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(let ()</font></div><div><font face="Courier New">  (bind-1 x)</font></div><div><font face="Courier New">  (void))</font></div><div><font face="Courier New">(ref-1 x)</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(ref-2 x)</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(let ()</font></div><div><font face="Courier New">  (bind-2 x))</font></div></div><br><div><div>On May 26, 2014, at 1:15 PM, Robby Findler <<a href="mailto:robby@eecs.northwestern.edu">robby@eecs.northwestern.edu</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">This does something. Not sure if it what you have in mind. The pink<br>arrows are showing the tail positions. I broke that with the values<br>expression, but you also wouldn't see it if 'bind' and 'ref' were in<br>separate modules.<br><br>Robby<br><br><br>#lang racket<br><br>(begin-for-syntax<br>  (define vars (make-hash))<br>  )<br><br>(define-syntax (bind stx)<br>  (syntax-case stx ()<br>    [(bind id)<br>     (let ([sym (syntax-e #'id)])<br>       (hash-set! vars sym (syntax-local-introduce #'id))<br>       #'(void))]))<br><br>(define-syntax (ref stx)<br>  (syntax-case stx ()<br>    [(ref id)<br>     (let* ([sym (syntax-e #'id)]<br>            [def-id-stx (hash-ref vars sym)])<br>       (with-syntax ([def-id (syntax-local-introduce def-id-stx)])<br>         #'(let ([def-id (void)])<br>             (values id))))]))<br><br>(bind x)<br>(ref x)<br><br>On Mon, May 26, 2014 at 10:33 AM, Alexander D. Knauth<br><<a href="mailto:alexander@knauth.org">alexander@knauth.org</a>> wrote:<br><blockquote type="cite">Is this what you meant?<br><br>It doesn’t work, and it also draws a pink arrow (that I don’t want) from the<br>x in (ref x) to the beginning of the let expression in the definition of<br>ref,<br>and also, if I put a let around the (ref x), it also draws another pink<br>arrow (that I don’t want) from the beginning of the let expression in the<br>definition of ref to the beginning of the let expression around (ref x).<br><br>#lang racket<br><br>(begin-for-syntax<br>  (define vars (make-hash))<br>  )<br><br>(define-syntax (bind stx)<br>  (syntax-case stx ()<br>    [(bind id)<br>     (let ([sym (syntax-e #'id)])<br>       (hash-set! vars sym #'id)<br>       #'(void))]))<br><br>(define-syntax (ref stx)<br>  (syntax-case stx ()<br>    [(ref id)<br>     (let* ([sym (syntax-e #'id)]<br>            [def-id-stx (hash-ref vars sym)])<br>       (with-syntax ([def-id (datum->syntax def-id-stx sym def-id-stx)]<br>                     [ref-id (datum->syntax def-id-stx sym #'id)])<br>         #'(let ([def-id (void)])<br>             ref-id)))]))<br><br>(bind x)<br>(ref x)<br><br>Any suggestions?<br><br>Anything I’m doing wrong?<br><br>On May 26, 2014, at 12:05 AM, Robby Findler <<a href="mailto:robby@eecs.northwestern.edu">robby@eecs.northwestern.edu</a>><br>wrote:<br><br>Oh, check syntax just collects the identifiers it finds in the<br>properties and, if the identifiers are free-identifier=? to each<br>other, draws an arrow. I'm not sure what behavior you want here, but<br>maybe the best thing is if you just expand into some dead code that<br>has lets in the way that you want the arrows to be.<br><br>Robby<br><br>On Sun, May 25, 2014 at 9:49 PM, Alexander D. Knauth<br><<a href="mailto:alexander@knauth.org">alexander@knauth.org</a>> wrote:<br><br>It’s working, but I have no Idea how to show lexical scoping<br><br>If I have this:<br>(bind x)<br>(ref x)<br>It works like I want it to work.<br><br>Also for some reason this works:<br>(let ()<br> (bind x)<br> (void))<br>(ref x)<br>Which is good I guess in some ways, but still weird.<br>It’s good because it gives me a chance to define my own lexical scoping<br>rules, but how do I do that?<br><br>I think it has something to do with the 2 xs having the same syntax-marks,<br>but I’m not sure.<br><br>The problem is that I can’t make them have different syntax-marks.  To do<br>this I think I would have to use (make-syntax-introducer) instead of<br>syntax-local-introduce, but for some reason that’s not working.<br><br>If I change the definition of stx-introducer from syntax-local-introduce to<br>(make-syntax-introducer), then it doesn’t work.  I don’t really know what<br>I’m doing here, but I think that If I want to have different references in<br>different scopes point to only their own respective definitions (lexical<br>scoping), then I think I would have to use (make-syntax-introducer) instead<br>of syntax-local-introduce.  But that’s not working, so then how do I do<br>that?<br><br>#lang racket<br><br>(begin-for-syntax<br> (define stx-introducer syntax-local-introduce)<br> ;; (define stx-introducer (make-syntax-introducer))<br> )<br><br>(define-syntax (bind stx)<br> (syntax-case stx ()<br>   [(bind-1 id)<br>    (let ([new-id (stx-introducer #'id)] [id.length (string-length<br>(symbol->string (syntax-e #'id)))])<br>      (syntax-property #`(void)<br>                       'sub-range-binders<br>                       (list (vector new-id 0 id.length new-id 0<br>id.length))))]))<br><br>(define-syntax (ref stx)<br> (syntax-case stx ()<br>   [(ref-1 id)<br>    (syntax-property #'(void)<br>                     'disappeared-use<br>                     (list (stx-introducer #'id)))]))<br><br>(let ()<br> (bind x)<br> (void))<br>(ref x)<br><br>On May 25, 2014, at 6:00 PM, Robby Findler <<a href="mailto:robby@eecs.northwestern.edu">robby@eecs.northwestern.edu</a>><br>wrote:<br><br>Yes. One approach is to expand into a program that never runs but that<br>has the identifiers in the binding relationships you want check syntax<br>to show. Another approach is to add properties to your program that<br>tells check syntax what to draw. You can read about the second<br>approach here:<br><br><a href="http://docs.racket-lang.org/tools/Check_Syntax.html?q=check%20syntax#%28part._.Syntax_.Properties_that_.Check_.Syntax_.Looks_.For%29">http://docs.racket-lang.org/tools/Check_Syntax.html?q=check%20syntax#%28part._.Syntax_.Properties_that_.Check_.Syntax_.Looks_.For%29</a><br><br>Let us know if you get stuck when you try it!<br><br>Robby<br><br>On Sun, May 25, 2014 at 2:41 PM, Alexander D. Knauth<br><alexander@knauth.org> wrote:<br><br>Is there any way to use syntax properties or anything like that to tell<br>DrRacket where to draw the arrows to?<br><br>I’m trying to make my own language and I wanted to be able to have DrRacket<br>draw the arrows.<br><br>Also is there a way to have it draw multiple arrows, so that for example it<br>would draw arrows not only to the original definition but also to all of the<br>expressions that set! it?<br><br><br>____________________<br>Racket Users list:<br>http://lists.racket-lang.org/users<br><br><br><br></blockquote></blockquote></div><br></body></html>