Microsoft working on new systems language
Marco Leise
Marco.Leise at gmx.de
Tue Dec 31 00:15:52 PST 2013
Am Mon, 30 Dec 2013 13:52:28 +0000
schrieb "ponce" <contact at gam3sfrommars.fr>:
> > http://www.reddit.com/r/programming/comments/1tzk5j/the_m_error_model/
> As compared with D:
>
> - unrecoverable errors crash immediately like they should. I like
> it since the most sensible reason to catch Error in D is to crash
> anyway (in eg. C callbacks).
»Unrecoverable errors are designed for conditions that can’t
really be handled appropriately from within a software
component. [...] Null dereferences, out-of-bounds array
accesses, bad downcasts, out-of-memory, contract/assertion
violations…«
»[...] all failures are recoverable, but the granularity is
much coarser grained than in traditional systems.«
As far as I can tell he is talking about tearing down a failing
component (e.g. a library or plugin), not the whole program. I
can only assume that he didn't look into bringing C code into
the mix.
This is different from D where you typically either get an access
violation or an attempt at stack unwinding down to D main().
»if one component fails in an unrecoverable way, an external
component can observe and/or recover from the failure of
that component.«
> - hence, unrecoverable errors exception hierarchy not represented.
Personally I think it is useful to be able to check the type
of unrecoverable error to handle out of memory situations or
checks in test cases and unit tests.
> - a throws keyword instead of nothrow. I expect it will lessen M#
> support for code made in a hurry (something that D shines
> particularly).
Can both co-exist? E.g. use case 1) "doesn't throw anything
ever", use case 2) "throws UtfException when the date string
is not valid UTF-8 and DateException when the day of month is
out of range", use case 3) no keyword since we are in a hurry.
> - same remark about the "try" keyword at call-site when calling a
> function which throw recoverable errors.
»In fact, if you call a method that might raise a
recoverable error, the call must be annotated to indicate
that it might throw (the keyword we use is “try”).«
I'm not quite sure if that means "directly at the call-site"
or "somewhere up in the call stack". What do you think?
--
Marco
More information about the Digitalmars-d
mailing list