It looks like it uses setjmp/longjmp for error handling. Is there a way to ensure Janet never calls setjmp/longjmp? If not, it won't be embeddable in Rust (and maybe C++?) due to RAII.
Janet uses setjmp/longjmp for error handling because most alternatives in C don't compose well or are incredibly verbose/inefficient. The C API is not documented yet, but in general one could use setjmp at C++/Rust <-> C boundary points to prevent panics from jumping over C++/Rust stack frames. However, many functions in the C API will not panic (longjmp to the last save point). The overhead could be minimized by only calling setjmp for API calls that can panic.
Handling exceptions might be different in Janet compared to perl, but it is possible to handle them while being embedded. You could essentially try/catch around every ffi boundary, which is the point brought up in this talk at 14.45
I ran into this earlier with Lua for different reason, and recently discovered PHP does this too. Maybe we just need to find a way around it? I was thinking of trying to bridge jumps with the Rust panic mechanism. (Basically try-catch at each boundary.)
I’m on my phone so I can’t get into it, but there were bugs around this with lua and rust that got resolved, so there is some way of dealing with this.