- `struct env` moved and `struct env` stores
a pointer to an environment now as well.
this is necessary to correctly evaluate
functions at a later point in time. consider
(cons 1 2)
which returns a function that binds arg1=1
and arg2=2. later, either arg1 or arg2
will be accessed when doing
(car (cons 1 2)) -> 1
(cdr (cons 1 2)) -> 2
- debug_tval and debug_env has been added to
show token or environments.
- add several reassure statements to verify
the validity of the code.
- remove unnecessary 2nd environmental flag
for eval().
[ i thought this might be
necessary to properly evaluate function
calls but it turns out it's not
necessary ]
- add new function eval_lm(). this one
should make the code structure cleaner
and other custom forms have their own
function as well.
while there, remove debugging code as well
- remove eval_fn_name function (this one is
actually not necessary)
- cleanup and implement eval_fn_call to
call custom defined functions. most of
the former code has been removed and newly
implemented.
some examples that work now:
(def cons (lm (x y) (lm (z) (if z x y))))
(def cell (cons 1 2))
(def cell2 (cons 3 cell))
(cell2 t) -> 3
(cell2 nil) -> #fn
((cell2 nil) t) -> 1
(cell2 nil) nil) -> 2
(def inc (lm (x) (add x 1)))
(inc 1) ; -> 2
(def inc2 (lm (x) (inc (inc x))))
(inc2 2) -> 4
[ more testing is still necessary ]
- BUGS section added
- small formatting updates here and there,
whitespace removal etc.
previously, lambda wasn't evaluated if it was the first
element of a list. it should be possible to evaluate
calls like
((lm (x) (add x 1)) 55) ->
now.
- add reassure() function with useful error
messages
- format code, with 65 cols max
- don't allow multiple definitions in one
environment
- prepare eval of defined symbols
- prepare eval of lambda/functions
prepare function call handling: till now, i've
just eval'ed new tokens but i think that i have
to distinguish a function call from a symbol
evaluation.
- this commit adds the boolean type with the
NAND operation (which is complete and other
operations can be built by using NAND)
- read from now reads until an entire form
has been entered. line breaks, whitespace
and tabs are allowed.