News for hackers. Stuff that matters.
Re:Janet – A dynamic language and bytecode VM by m0th87 on Sunday February 17, 2019 @02:50PM (#19186423)
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.
Re:Janet – A dynamic language and bytecode VM by bakpakin on Sunday February 17, 2019 @05:31PM (#19187312)
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.

Just spitballing here.

Re:Janet – A dynamic language and bytecode VM by cbcoutinho on Sunday February 17, 2019 @06:24PM (#19187558)
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

https://youtu.be/gwmtFzggE18

Re:Janet – A dynamic language and bytecode VM by kosinus on Sunday February 17, 2019 @04:44PM (#19187112)
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.)
Re:Janet – A dynamic language and bytecode VM by steveklabnik on Sunday February 17, 2019 @05:51PM (#19187407)
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.