Comparing Exceptions and Errors
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Sun Jun 5 06:31:42 UTC 2022
On Sunday, 5 June 2022 at 00:40:26 UTC, Ali Çehreli wrote:
> Errors are thrown when the program is discovered to be in an
> invalid state. We don't know what happened and when. For
> example, we don't know whether the memory has been overwritten
> by some rogue code.
That is not very probable in 100% @safe code. You are basically
saying that D cannot compete with Go and other «safe» languages.
Dereferencing a null pointer usually means that some code failed
to create an instance and check for it.
My code can detect that the failure is local under the assumption
thay the runtime isnt a piece of trash.
> What happened? What can we assume. We don't know and we cannot
> assume any state.
So D will never be able to provide actors and provide fault
tolerance.
> Is the service in a usable state?
Yes, the actor code failed. The actor code change frequently, not
the runtime kernel.
> Possibly. Not shutting down might produce incorrect results. Do
> we prefer up but incorrect or dead?
I prefer that service keeps running: chat service, game service,
data delivered with hashed «checksum». Not all software are
database engines where you have to pessimize about bugs in the
runtime kernel.
If the data delivered is good enough for the client and better
than nothing then the service should keep running!!!
> I hope there is a way of aborting the program when there are
> invariant
Invariants are USUALLY local. I dont write global spaghetti
code. As a programmer you should be able to distinguish between
local and global failure.
You are assuming that the programmer is incapable of making
judgements. That is assuming way too much.
More information about the Digitalmars-d-learn
mailing list