Herb Sutter briefly discusses D during interview

Jonathan M Davis jmdavisProg at gmx.com
Tue Jun 7 20:35:49 PDT 2011


On 2011-06-07 19:41, Steven Schveighoffer wrote:
> On Tue, 07 Jun 2011 22:31:20 -0400, Jonathan M Davis <jmdavisProg at gmx.com>
> 
> wrote:
> > On 2011-06-07 17:32, Andrei Alexandrescu wrote:
> >> There's a question related to D and Go within the first eight minutes:
> >> 
> >> http://channel9.msdn.com/Shows/Going+Deep/Herb-Sutter-C-Questions-and-An
> >> swe rs
> > 
> > I find it interesting that C++0x's noexcept is still a runtime feature
> > like
> > exception specifications rather than going the static route that D's
> > nothrow
> > does. It'll be easier to implement that way, I expect, given that C++
> > compilers are already implementing exception specifications, but having
> > it be
> > statically-checked definitely has advantages. At least it's an
> > improvement
> > over exception specifications regardless.
> 
> IIRC, there is already a way to statically declare that a function doesn't
> throw any exceptions.  I think you do it with throws().  I could be wrong
> though, haven't used C++ in a while, and even when I did use it, I stayed
> away from exception specifications, having a bad experience with them.

No, those are the exception specifications that he was talking about. It's all 
done at runtime, and if your function violates them, it kills your program. 
That's why it's generally considered good practice to only ever use throws() 
(which indicates that nothing is thrown), and even that isn't necessarily used 
much. Otherwise, if anything unexpected is ever thrown, it kills your program. 
noexcept is essentially identical to throws(). C++ has no features for 
statically verifying which exceptions are or are not thrown.

- Jonathan M Davis


More information about the Digitalmars-d mailing list