Sun Mar 23 18:36:38 EDT 2008
what is dict?
the incremental compilation has type (DICT,SRC) -> (DICT,BIN)
so what type is DICT?
It needs to be something that can be serialized, so what about plain
s-expressions? Is there information that cannot be captured?
One problem is that arbitrary extensions might depend on external
code. Representation should probably be a 'module' form which
explicitly states its dependencies. Problem solved. Module forms are
neatly representable by s-expressions since they have no free
Now how to go about this?
A dictionary is a module that exports a function 'update' which takes
forth source code, and outputs the expression of another module and
This is interesting: it involves writing a "module quine" ;)
EDIT: when you can modify the language in which to write a quine, the
problem is trivial. the reason why some quines are interesting is the
length it can take to express one in some language / system, or the
extent to which detours can be taken..
It almost works, except for some constant redefinition errors.
OK. got it working with arbitrary payload and update expression. some
interplay between macros and s-expression code generation: on each
* apply the update expression to the state
* pass on the update expression
* send the output
very straightforward iterative system once the boilerplate generator
is in place. this can be minimised by re-defining %plain-module-begin
updates: can probably standardize the module name, since only one is
necessary and it can be loaded into a sandbox.
stylized the reflection loop a bit: now using #%module-begin macro and
a minimalistic module spec which also carries over the body code.
cleaned it up to a single macro:
(define-syntax (module-begin stx)
(syntax-case stx ()
((_ (tick state) . forms)
(define (update input)
(let-values (((state+ output) (tick 'state input)))
`(module #,name scat/forth-dict
(tick ,state+) . forms))))
so state update / storage is solved.