[racket] Arrows in DrRacket

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Mon May 26 00:05:58 EDT 2014

Oh, check syntax just collects the identifiers it finds in the
properties and, if the identifiers are free-identifier=? to each
other, draws an arrow. I'm not sure what behavior you want here, but
maybe the best thing is if you just expand into some dead code that
has lets in the way that you want the arrows to be.

Robby

On Sun, May 25, 2014 at 9:49 PM, Alexander D. Knauth
<alexander at knauth.org> wrote:
> It’s working, but I have no Idea how to show lexical scoping
>
> If I have this:
> (bind x)
> (ref x)
> It works like I want it to work.
>
> Also for some reason this works:
> (let ()
>   (bind x)
>   (void))
> (ref x)
> Which is good I guess in some ways, but still weird.
> It’s good because it gives me a chance to define my own lexical scoping rules, but how do I do that?
>
> I think it has something to do with the 2 xs having the same syntax-marks, but I’m not sure.
>
> The problem is that I can’t make them have different syntax-marks.  To do this I think I would have to use (make-syntax-introducer) instead of syntax-local-introduce, but for some reason that’s not working.
>
> If I change the definition of stx-introducer from syntax-local-introduce to (make-syntax-introducer), then it doesn’t work.  I don’t really know what I’m doing here, but I think that If I want to have different references in different scopes point to only their own respective definitions (lexical scoping), then I think I would have to use (make-syntax-introducer) instead of syntax-local-introduce.  But that’s not working, so then how do I do that?
>
> #lang racket
>
> (begin-for-syntax
>   (define stx-introducer syntax-local-introduce)
>   ;; (define stx-introducer (make-syntax-introducer))
>   )
>
> (define-syntax (bind stx)
>   (syntax-case stx ()
>     [(bind-1 id)
>      (let ([new-id (stx-introducer #'id)] [id.length (string-length (symbol->string (syntax-e #'id)))])
>        (syntax-property #`(void)
>                         'sub-range-binders
>                         (list (vector new-id 0 id.length new-id 0 id.length))))]))
>
> (define-syntax (ref stx)
>   (syntax-case stx ()
>     [(ref-1 id)
>      (syntax-property #'(void)
>                       'disappeared-use
>                       (list (stx-introducer #'id)))]))
>
> (let ()
>   (bind x)
>   (void))
> (ref x)
>
> On May 25, 2014, at 6:00 PM, Robby Findler <robby at eecs.northwestern.edu> wrote:
>
>> Yes. One approach is to expand into a program that never runs but that
>> has the identifiers in the binding relationships you want check syntax
>> to show. Another approach is to add properties to your program that
>> tells check syntax what to draw. You can read about the second
>> approach here:
>>
>>  http://docs.racket-lang.org/tools/Check_Syntax.html?q=check%20syntax#%28part._.Syntax_.Properties_that_.Check_.Syntax_.Looks_.For%29
>>
>> Let us know if you get stuck when you try it!
>>
>> Robby
>>
>> On Sun, May 25, 2014 at 2:41 PM, Alexander D. Knauth
>> <alexander at knauth.org> wrote:
>>> Is there any way to use syntax properties or anything like that to tell DrRacket where to draw the arrows to?
>>>
>>> I’m trying to make my own language and I wanted to be able to have DrRacket draw the arrows.
>>>
>>> Also is there a way to have it draw multiple arrows, so that for example it would draw arrows not only to the original definition but also to all of the expressions that set! it?
>>>
>>>
>>> ____________________
>>>  Racket Users list:
>>>  http://lists.racket-lang.org/users
>


Posted on the users mailing list.