Last active
January 1, 2016 14:31
-
-
Save Glorp/044567d03ba9e29e0935 to your computer and use it in GitHub Desktop.
DrRacket-arrows?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(provide (rename-out [my-read read] | |
[my-read-syntax read-syntax])) | |
(define (my-read in) (syntax->datum (my-read-syntax #f in))) | |
(define (my-read-syntax src in) | |
(define a (read-syntax src in)) | |
(define b (read-syntax src in)) | |
(define res (datum->syntax a | |
(format "a: ~a~nb: ~a~n" | |
(syntax-property-symbol-keys a) | |
(syntax-property-symbol-keys b)))) | |
(datum->syntax a | |
`(module foo racket | |
(define ,(datum->syntax a 'foo a a) 0) | |
,(datum->syntax b 'foo b b) | |
(display ,res)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(provide (rename-out [my-read read] | |
[my-read-syntax read-syntax])) | |
(define (my-read in) (syntax->datum (my-read-syntax #f in))) | |
(define (my-read-syntax src in) | |
(define a (read-syntax src in)) | |
(define b (read-syntax src in)) | |
(define res (datum->syntax a | |
(format "a: ~a~nb: ~a~n" | |
(syntax-property-symbol-keys a) | |
(syntax-property-symbol-keys b)))) | |
(datum->syntax b | |
`(module foo racket | |
(define ,(datum->syntax a 'foo a) 0) | |
,(datum->syntax b 'foo b) | |
(display ,res)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang reader "lang1.rkt" | |
a | |
b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang reader "lang2.rkt" | |
a | |
b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using lang1.rkt or lang2.rkt as a reader-lang:
test1.rkt uses lang1.rkt as reader-lang, test2.rkt uses lang2.rkt. Other than that the content of test1.rkt is equal to the content of test2.rkt.
Any program with two s-expresions is a valid program.
Every valid program is transformed into
where the first
foo
uses the source location of the first s-expression in the input program and the secondfoo
uses the source location of the second s-expression. (also does some printing of syntax-properties).foo
is turned into syntax-object with(datum->syntax ctxt v [srcloc prop ignored])
In lang1.rkt the "input" syntax objects from the program we are reading are used for
ctxt
,srcloc
andprop
. In lang2.rkt they are only used forctxt
andsrcloc
.DrRacket arrows?
The programs behave the same in both languages, but DrRacket only draws the "bound occurence" arrow on mouseover for the program that uses lang1.rkt. (draws an arrow from
a
tob
in test1.rkt, since those expressions are used for source locatoins for the differentfoo
s, but not in test2.rkt).So, I'm not super-sure about how DrRacket decides which arrows to draw, but so far I've only been able to get them by using syntax-objects I've got from the regular Racket
read-syntax
asprop
.also
I've tried moving the arrow around by using different
srcloc
, which works fine/as expected. E.g. using(list src #f #f 10 10)
assrcloc
for the firstfoo
makes the arrow go from somewhere in the #lang-line.Also tried using different syntax objects for
prop
, and things seem to work fine as long as the syntax object is produced by the regular Racketread-syntax
(works fine with e.g.(read-syntax #f (open-input-string "e"))
)