Nothrow, pure in druntime

Walter Bright newshound1 at digitalmars.com
Sun Jan 25 12:27:51 PST 2009


dsimcha wrote:
> I assume, when referring to the ones that do throw, you mean functions written in
> C++ or D, but declared w/ C linkage.  If so, you could make this a per-module
> setting that defaults to not assuming nothrow.  For example, let's say you made
> this pragma(Linkage, nothrow).  Then, if this statement is seen at the top of a
> module, everything declared with extern(Linkage) in that module is assumed to be
> nothrow.  For standard C, Windows and POSIX API functions and for any library
> written in pure C, I believe (correct me if I'm wrong) this would be a safe
> assumption.  At any rate, it would make nothrow a heck of a lot more usable.

This will do it:

nothrow:
... rest of module ...


> Isn't errno defined in some implementations to be thread-local?

Yes, but thread local doesn't mean pure.

> If so, I guess we
> still have a problem.  Then again, in the long run it probably makes sense to
> reimplement a lot of the math stuff that still uses the C std lib in pure D anyhow
> so that things like CTFE work on it, but in the sort run I'm sure that's not
> anyone's top priority.

Don has already reimplemented most of them in D, this was done to:

1. ensure a minimum level of performance and accuracy; some C ones are 
crappily done

2. properly support all the D floating point types and overloading rules

3. support NAN and INFINITY correctly



More information about the Digitalmars-d mailing list