I understand your desire, but internally at some point newLISP has to drop down into dealing with C-language style of functions and data structures. That C function evaluateExpression(CELL * params) is called about 200 times throughout the newLISP executable also calls itself and many times inline coded shorter alternatives are used for efficiency. There is just no way it could be replaced with a user defined eval internally.
But you could write e McCarthy style newLISP evaluator yourself and then put as much customization into it, as you need. You would also emulate a REPL, which is pretty easy using 'read-line', 'read-expr' and your customized evaluator function. You also would use 'quote' instead of the newLISP pre-compiled "'".
Code: Select all
(define (repl)
(while true
(print ">> ")
(catch (eval (read-expr (read-line))) 'result)
(println "--> " result)
)
)
(repl)
and you would replace 'eval' with your McCarthy style eval. The 'read-expr' function returns an un-evaluated s-expression translation of the string returned by 'read-line'. On errors 'result' will contain the error message.