riff-lang / riff

The Riff programming language
https://riff.cx
BSD Zero Clause License
23 stars 1 forks source link

Add proper error handling/unwinding #37

Open darrylabbate opened 1 year ago

darrylabbate commented 1 year ago

The interpreter currently prints some message to stderr and immediately exits whenever a given error is encountered. There needs to be a more robust system in place s.t. various callers can properly unwind.

This will be a little tricky wrt the VM, especially builtin functions. I'd rather not have the VM check the return status every time a C function is called. It probably makes more sense to pass the global riff_state struct around (similar to Lua). That way errors can continue to be directly thrown from anywhere in the interpreter, and some dedicated error handler (state.c?) can do any necessary unwinding.