need to be able to raise an error
john-science opened this issue · comments
John Stilley commented
Some part of this will have to be implemented in Python. Perhaps a syntax something like:
(raise "Out of Bounds Error")
This could be implemented in lisp, if we have an exit statement:
(def raise
(lambda (s)
(print (string_append "Error: " s) exit)))
(def raise
(lambda (typ str)
(print (string_append (string_append typ ": ") s) exit)))
(def raise_lisp_error
(lambda (str)
(raise "Lisp Error" str)))
(def raise_bounds_error
(raise "Bounds Error" "Index out of bounds."))
John Stilley commented
Here is some example implementation code for exit:
elif ast[0] == 'exit':
return eval_exit(ast, env)
def eval_exit(ast, env):
assert_exp_length(ast, 1)
exit()
John Stilley commented
There is a problem with the string implementation:
(raise "hi")
! LispError:"hi" not in the environment.