Looking at some of the recent tutorials on building and using languages in Racket, I was prompted to wonder what I'd have to do in order to take an existing module (in its own file) and evaluate it with a language other than the one it is specified to use, without modifying the module's original source file. E.g., take a BSL module containing
;; hi : String -> String (define (hi person) (string-append "Hi, " person "!")) and evaluate it in a different language. This is what I've come up with so far, which seems to do the trick: (require racket/sandbox) ;; mod-path->evaluator : path module-path -> (any -> any) (define (mod-path->evaluator p replacement-lang) (parameterize ([read-accept-reader #t]) (let ([mod (read (open-input-file p))]) (match mod [(list 'module name lang body ...) (make-module-evaluator `(module ,name ,replacement-lang ,@body))])))) The explicitness of destructuring and rebuilding of the module bugs me a bit, but assuming that replacement-lang* *defines all the forms used in the module's intended language, is this more or less the way that those of you who have built plenty of languages in Racket would do it? Any suggested improvements? That said, it's still pretty neat to see how easily this was done once I found the necessary parts. jmj
____________________ Racket Users list: http://lists.racket-lang.org/users