Re: Try/Catch
- Posted by mattlewis (admin) Feb 11, 2015
- 4548 views
Since incorrect indexes are the most common exception in Euphoria, you're suggesting that we adopt a solution known to leave the majority of use cases in place.
I've been thinking about this. We don't currently do any bounds checking in compiled code. The standard line (since the translator came into being) was that you would debug your code in the interpreter and then port over. Some of the speedup is that the bounds checking isn't done. So these turn into segfaults or other low level memory errors.
So, in translated code, we could ignore this particular type of exception. We could start adding bounds checking everywhere. We could detect when code is directly inside a try block and add bounds checking / exception throwing code. The translator would have to do a lot of checks to determine which functions are called inside of a try block (we already do a lot of iteration, so this isn't the end of the world). Similar issues apply for other translator things where we omit error checking.
Explicit throws seem easier to figure out.
Matt