With most of the R5RS primitives implemented, it's time to get back to the interpreter proper.
At this point, the interpreter is almost ready to run the metacircular evaluator from SICP chapter 4. The idea of running a scheme interpreter in the scheme interpreted by minime is ... tempting. All it needs is the 'let' binding construct and a couple of more primitives: display, newline, read, apply.
It would be easy to add to the C interpreter the required source transformation from let forms to lambda forms and be done with it.
However, let can also be implemented using macros, along with other non-primitive forms like cond, case, let*, letrec, etc.
Since I will have to properly understand macros anyway while writing the compiler, I'm taking a pause and doing some reading. Perhaps I will implement the remaining constructs as macros after all.
There's one additional aspect I didn't think of yet: continuations.
A continuation is some kind of object that represents the future of the computation. It is a callable object not unlike a regular procedure (this is me passing subtle implementation hints to myself :-) They can be used to resume some computation from a point where it left off, for example for non-local exits.
I don't fully understand all there is to continuations (particularly about their extent) so more reading is in order. At a first glance, they can be added as a callable type that wraps a C jmpbuf. I'm not sure that's enough.
miercuri, 20 ianuarie 2010
Abonați-vă la:
Postare comentarii (Atom)
Niciun comentariu:
Trimiteți un comentariu