[racket-dev] define #lang and use in same file (+ some funny behavior)
When doing quick experiments, I've often wanted the ability to define
a new language and then use it in the same file. I thought submodules
might allow me to do this, but I've realized that I still can't.
However, in trying to do so I ran into some interesting behavior:
Here is a file named test.rkt that is saved to disk:
#lang racket
(define-syntax-rule (app x ...) (begin (displayln "hello") (#%app x ...)))
(provide (except-out (all-from-out racket) #%app)
(rename-out [app #%app]))
If I then add to the same file:
(module test "test.rkt" (+ 1 2))
but *don't* save, pressing run in drracket displays:
Welcome to DrRacket, version 5.3.1.1 [3m].
Language: racket [custom].
hello
3
>
Then if I save and run again, I get an error:
Welcome to DrRacket, version 5.3.1.1 [3m].
Language: racket [custom].
. . ../plt/collects/compiler/cm.rkt:350:0:
standard-module-name-resolver: cycle in loading
at path: /home/stchang/tmp/test.rkt
paths:
/home/stchang/tmp/test.rkt
>
Is this the intended behavior? I guess this is what I would expect but
it feels funny since an identical buffer produces different output
depending on it's saved status.