Safe Random Access Collection Element

Just to throw it out there... another way to look at the issue is that such seemingly simple to make mistakes have such fatal (pun intended) consequences.

Rather, we would want to yes aborting execution but still not taking down the entire process but perhaps the thread (and bubble it up to the event loop, thread pool, dispatch queue, something else) which was running the computation (i.e. "panics" or "soft faults") which have been discussed here and there (e.g. [stdlib] Cleanup callback for fatal Swift errors - #4 by ktoso) a while ago.

This would allow for some more control of the crashing behaviors; by default the behaviors would remain the same, but depending on runtime they could mean not necessarily taking down the entire process (noted, my use cases for this are server biased, though wanted to bring it up here as well – since that seems to be the root of why fatal errors are such a pain IMHO).


Having that said, I would not mind such a safer (returning option) indexing into arrays...
but also not sure it solves the actual root cause. what causes these troubles.

1 Like