[plt-scheme] Inlined language from a language module

From: Neil Toronto (ntoronto at cs.byu.edu)
Date: Fri Mar 20 12:46:34 EDT 2009

I'm writing an s-expression-based DSL for statistical inference called
RevBayes. It's currently defined in a language module, which is great
because I *must* have tight control over the identifiers the DSL has
access to.

The problem is, the only reason to write code in this DSL is to reason
about the models the code represents. The statistical reasoning (written
in Scheme) and the model (written in RevBayes) are necessarily tightly
coupled, and having the two in separate files makes it difficult to keep
them in sync.

Also, making test cases hurts.

What I'd like is a way to inline RevBayes code with a macro, and have it
expand exactly as if it had been defined in a separate module. I've made
something that almost works using eval in a separate namespace, but 
that's icky and doesn't play well with other macros. I'm currently 
searching out implementation strategies.

One way is to keep the language module as-is and use local-expand inside 
the inlining macro. But there's a load of added complexity with managing 
internal definition contexts. (Aside: is there a nice way to bind in a 
def-ctx all the bindings from the current namespace?)

Another is to make most of the language module macros expand to uses of 
the inlining macro and have that do all the parsing. But then I have the 
namespace problem.

Ideas?

Neil



Posted on the users mailing list.