Tue Jul 24 19:02:23 CEST 2007
really on top of scheme
so, i need to get rid of the explicit interpreter. or not? i'm mostly
concerned with name spaces here, not implementation.
(1 2 +) ->
(lambda stack (apply cat:+ (cons 2 (cons 1 stack))))
what about preserving original source form? do i actually still use
that? yes, when printing code. for example, doing (1 2 +) creates a
quoted CAT program, which when compiled doesn't have a source form.
so, how to assoicate original source form to lambda expressions?
i really should define my interface first. i don't need to use raw
functions as representations. the 'stuff' that's bound to names can
just as well remain a word structure. in the end, i'm doing nothing
but replacing hash tables by name spaces.
* modules: separate code into logic entitites
* namespaces: allow run-time eval/compile
the latter part is not really necessary for the core! so, i should
build macros first, make sure i have a direct map from:
CAT (or any monad language derivative) -> 'raw' cat -> scheme
raw cat is just cat with scheme words.
so how to do this?
- all CAT code is compiled: use modules
- how to separate name spaces: (i.e. how to prefix names?)
so.. it's seeping through. names are compile time stuff. macros are
compile time stuff. anything that juggles names should be a macro. so
(cat +) is a macro, which expans to a labda expression, or a variable.
it's not enough to have it expand to just a lambda expression. storage
should be shared, so (cat +) should return a binding in case of a
single expression, or a composition (cat 1 +) in case of multiple
so, what about this:
any CAT-like languages use the (<language>: <word> <word> ...)
syntax, where the macro <language>: (i.e. 'cat:') transforms the
code into a function that maps stack -> stack
this way everything is directly accessible from scheme. for example
(cat: 1 +) is a lambda expression. neat. even, ':' could signify THE
cat. then 'cat-compile' is no more than (eval (cons 'cat: src))
note that i don't really need to ever run any programs. cat is just
functions, and in scheme, they can be applied to data.
the thing is, i don't need an interpreter. i just need a proper way to
associating compiled code to original source form (reflection). this
does mean giving up some reflection: the current source/semantics
association probably needs to change. it's not a small rewrite..