[plt-scheme] annotated lambda

From: Tom Schouten (tom.goto10.org at gmail.com)
Date: Thu Jul 26 06:01:29 EDT 2007


I'm working on a forth compiler which uses an intermediate functional
compositional language (CAT) modeled after the Joy language to
implement the forth macros in. Until now I've used an explicit interpreter
to implement the CAT language, for ease of debugging. The feature
used the most is 'print stack'. A possible output might look like:

<2> 1 (1 +)

This indicates 2 elements on the stack. The number 1 and the quoted
program (1 +). The language elements themselves are represented as
scheme functions (stack -> stack). I.e. the function '(1 +)' might be
(lambda (a . stack) (cons (+ 1 a) stack)), and the function '1' might be
(lambda stack (cons 1 stack))

Currently, I'm using a simple caching mechanism to speed up execution
a bit, so compilation is done only once, but i still have full access to the
source code for debugging purpose.

Each code atom has a the following information associated:
1. a source expression. 2. a function representing semantics
(source -> scheme fn) since there are different flavors of the language,
and 3. a cached scheme fn.

Now, I don't use this for much else than debugging, so i was wondering
how I could simplify my implementation by using only macros,
taking out the explicit interpreter.

This seems to be fairly straightforward. The problem however is that my
original source code information is lost.

So my question is, how can i annotate the functions I get in the end, to
associate them to their original source code, so my 'print stack' operation
still works?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20070726/4daa6db3/attachment.html>

Posted on the users mailing list.