Integrate run-time assertions with Céu Exceptions
Opened this issue · 1 comments
As of today, Céu apps
- pay the run-time overhead of checking each and every index against array bounds,
- ... but without reaping the benefits, IOW without offering a controlled way to react to the out of bounds situation.
The app just crashes usingceu_assert/abort
. This feals very unsatisfactory.
Ideally, when CEU_FEATURES_EXCEPTION is enabled, ceu_assert
should somehow lead to ceu_throw
such that I can write some error handler and e.g. let my game restart at the current level or whatever the programmer decides is appropriate.
Easier said than done. Céu's Exception appears akin to checked exceptions, whereas what is required here is run-time or unchecked exceptions.
Perhaps the internal assertions could be split in two groups: fatal ones, e.g. out of memory and internal consistency checks on one hand and recoverables ones like loop/limit
violations OTOH.
BTW, why can't code/call
locally catch an exception? (cf. src/tests.lua around line 45860) The internal reason appears to be that catch
expands to par/or
and finalize
, but what is the user story, how to teach that? (catch/throw
doesn't naïvely appear as a member of synchronous control statements to me.)
BTW, why can't code/call locally catch an exception?
It's an implementation limitation: code/call
blindly uses the C stack with no runtime overhead/intervention.