Closed phmarek closed 1 year ago
Sorry for the delay in replying. I agree that unwind-protect would be useful, but the action "restore the execution point to the saved one" is difficult because of the need to restore the state of the stack. I'll give it some more thought, but I suspect it will involve a major rewrite of uLisp.
Still thinking about this!
Whether it ends up in official uLisp or not, I found that @Goheeca and @m-g-r implemented (unwind-protect)
and a few other error-related functions. See these two links:
You'll have to apply the patches yourself. I did on my uLisp, and it works great.
EDIT: I will note here that when I tried to use (error)
it caused a Guru Meditation Error (i.e. a segfault), and so I had to replace it with a simpler (throwerrorstring)
(my own creation; not a special form which I think was the problem).
Now included in uLisp Release 4.4.
I'd like to have my ESP32 available via WIFI all the time. I've got a simple telnet REPL working; the one problem left is that some error (any error) breaks the Lisp REPL and returns to the serial console.
I'd imagine that
UNWIND-PROTECT
would set some variable to the current execution point (and croak if it's already set, to make it non-reentrable);error
anderror2
would check that variable, and when it's set store the current error in another variable (that can be queried from Lisp) and instead of doing thelongjmp(exception, 1)
they should restore the execution point to the saved one.So my REPL could just run something like