This repository houses a self-contained implementation of Peter Norvig's first essay on a simple Scheme implementation in Python (but in Rust, of course). It is not particularly well-factored or optimized, but was is meant as a learning exercise in interpreter implementation. In this regard, it continues to be instructive.
The codebase is well tested, with many examples demonstrating the use of all of the constructs contained herein.
- Hygenic Macros (do want
let
) - Some benchmarks:
fact(1000)
(can't be done before TCO lands)- Some kind of
Env
-copy/lambda
-centric benchmark to get data before working onEnv
/Expr
-passing refactor below
- Move away from by-val
Expr
passing for everything in the API.Env
will store justRc<Expr>
, instead ofExpr
eval
will takeRc<Expr>
s, as well as all of the helpers that fall out from it- In this way, the boxing is bottlenecked to boundary between
read
andeval
- Not worried about ensuring that there's only one instance of a given
Expr
value in all of theEnv
s; just that there's a net decreasein Expr
value copies - Probably has test fallout (can capture w/i
test_eval!
?)
- Build-scripting to guarantee against the reintroduction of
fail!
,unwrap
andexpect
(tidy.py
work? alsoprintln!
?) - API Documentation
result::SchemerResult
should change itsErr
component fromString
to take a newSchemerError
valueSchemerError
contains the module/type/method/function path of theErr
-ing code (wish this could be handled in a macro), along with theString
error component- This enables a more uniform error display in the REPL/elsewhere
- Generating the
Err
variant ofSchemerError
can be handled in a macro, and all makers ofSchemerResult
will be caught up in this change
- Tackle the (remaining) contents Peter Norvig's second essay on the same topic, notably:
- More
Atom
types (strings,bools, complex numbers, etc) - Better error detection/parsing
- Expanded list of primitive procedures
- The expanded test suite (would probably just adapt
lispytest.py
for this)
- More
- Implement a proper REPL