[racket] Evaluating Racket source files from within another Racket source file

From: Matthew Butterick (mb.list.acct at gmail.com)
Date: Sat Apr 27 12:56:03 EDT 2013

I'm building a website using Scribble as the source format. As a
development tool, I've built a web server in Python that lets me view all
my Scribble source files and look at them in different states of
processing. To view the results of the Scribble files, the Python server
just sends the files to Racket via a system command (os.Popen) and reads
the result. This works but it's slow, because it  has to launch a new
Racket thread for every request.

I thought I could speed things up by rewriting the development web server
in Racket. But having tried a few approaches, I'm not sure how to duplicate
this functionality within a Racket web servlet:

*(require <modulename>) *
This only gets evaluated once, when the server is started. That doesn't
help, since the <filename> is going to be passed in as a parameter while
the server is running.

*(dynamic-require <** modulename **>) *
This gets evaluated only when invoked, and thus can take <modulename> as a
parameter, but then <filename> can't be reloaded (this is essential, as the
point of the system is to be able to edit the files and see the changes in
the web browser immediately)

*(enter! <modulename>)*
This reloads the file, but it's not clear how to get access to names
provided by <modulename>. (The documentation for enter! suggests that this
is not how it's meant to be used anyhow.)

Obviously, I could call a new instance of Racket as a system command, but
that wouldn't offer any advantage over the current approach.


I suppose what I'm looking for is an equivalent of the Python
reload(<modulename>) command.


Matthew Butterick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130427/18945b48/attachment.html>

Posted on the users mailing list.