Arc Forumnew | comments | leaders | submitlogin
The Art of the Interpreter in Arc
11 points by dido 6123 days ago | 2 comments
I was reading Steele and Sussman's The Art of the Interpreter [1] the other day and decided to try implementing and adapting some of the code for metacircular interpreters there in Arc, essentially making an interpreter for some useful subset of Arc in Arc. It's been an enlightening experience doing this. It's on anarki, in the meta-interp directory.

The first interpreter, mk1.arc, is an interpreter of an Arc-like language that is somewhat limited, with no provision for free variables other than those produced by the def form, and no anonymous functions.

The second interpreter, mk2.arc, is an interpreter for an Arc dialect that does dynamic binding, making it sort of similar to a classic Lisp such as Lisp 1.5.

The third interpreter is getting closer to Arc, doing static/lexical binding with the exception of the top-level environment. It is a pure functional dialect with no side effects.

The fourth interpreter implements the set primitive and adds side effects and the do form.

Unsurprisingly, none of these metacircular interpreters is greater than a hundred lines in all, and they could probably be significantly simplified further.

I'm working on a fifth interpreter that follows Arc's internals a bit more closely, allowing the running of macros. If only I had the third part of the Art of the Interpreter... :)

[1] http://repository.readscheme.org/ftp/papers/ai-lab-pubs/AIM-453.pdf



1 point by sacado 6123 days ago | link

Nice idea ! You are more reasonable than I am. I was trying to write a meta-circular Arc->C compiler. For the moment, I can tell whether a value is a fixnum (and which one), t or nil. I don't know if I'll go any further :)

-----

1 point by almkglor 6123 days ago | link

Should have named it "Arc, in Arc" ^^

-----