[D-runtime] Is core.math public API?

David Nadlinger code at klickverbot.at
Tue Oct 2 10:43:52 PDT 2012

On Tue, Oct 2, 2012 at 6:48 PM, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> It's public in that it's public and that you _can_ use it directly […]

You can't currently in LDC (you'd just get a linker error), which is
exactly the reason I asked.

> but I think that it's like core.stdc.math in that you're not really supposed
> to use it.

There is a difference between "it's part of the public API, but our
own versions are better" and "it's not part of the public API, so you
can't expect it to be there". We have to get away from thinking that
having things completely implementation (i.e. DMD) defined is fine.

> I would point out however that those same intrinsics are listed in std.math […]

There is no such thing as "the same intrinsic" if two declarations are
different. How do you think intrinsics are matched by the compiler?
Surely, not any "real sin(real)" sin function is turned into a sin
call… ;)

Speaking of it, DMD matching mangled names in Phobos is a huge hack in
my (and Alex', IIRC) opinion. There simply should be no need to – what
are you going to do if you want to write an alternative library
containing that functionality (everything besides druntime is meant to
be swappable)?

> […] so either LDC expects the intrinsics and will blow up if you use them […]

I think you might have misunderstood something here: LDC is the one
responsible for _providing_ the intrinsics.


More information about the D-runtime mailing list