Thread overview | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
October 02, 2012 [D-runtime] Is core.math public API? | ||||
---|---|---|---|---|
| ||||
core.math contains a few magic declarations (cos, fabs, ldexp, rint, rndtol, rndtonl, sin, sqrt, yl2x) recognized by DMD as intrinsics for the respective math functions. Is the module actually public API? I would guess so, but the reason why I'm asking is that currently LDC does not implement them, but nobody has ever complained about linker errors so far. Also, http://dlang.org/phobos/core_math.html is not linked from the doc index in the sidebar on dlang.org. David _______________________________________________ D-runtime mailing list D-runtime@puremagic.com http://lists.puremagic.com/mailman/listinfo/d-runtime |
October 02, 2012 Re: [D-runtime] Is core.math public API? | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Nadlinger | It isn't. See: http://article.gmane.org/gmane.comp.lang.d.runtime/1187/match=core+math On Tue, Oct 2, 2012 at 6:43 PM, David Nadlinger <code@klickverbot.at> wrote: > core.math contains a few magic declarations (cos, fabs, ldexp, rint, rndtol, rndtonl, sin, sqrt, yl2x) recognized by DMD as intrinsics for the respective math functions. > > Is the module actually public API? I would guess so, but the reason why I'm asking is that currently LDC does not implement them, but nobody has ever complained about linker errors so far. Also, http://dlang.org/phobos/core_math.html is not linked from the doc index in the sidebar on dlang.org. > > David > _______________________________________________ > D-runtime mailing list > D-runtime@puremagic.com > http://lists.puremagic.com/mailman/listinfo/d-runtime _______________________________________________ D-runtime mailing list D-runtime@puremagic.com http://lists.puremagic.com/mailman/listinfo/d-runtime |
October 02, 2012 Re: [D-runtime] Is core.math public API? | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Nadlinger | On Tuesday, October 02, 2012 18:43:03 David Nadlinger wrote: > core.math contains a few magic declarations (cos, fabs, ldexp, rint, rndtol, rndtonl, sin, sqrt, yl2x) recognized by DMD as intrinsics for the respective math functions. > > Is the module actually public API? I would guess so, but the reason why I'm asking is that currently LDC does not implement them, but nobody has ever complained about linker errors so far. Also, http://dlang.org/phobos/core_math.html is not linked from the doc index in the sidebar on dlang.org. It's public in that it's public and that you _can_ use it directly, but I think that it's like core.stdc.math in that you're not really supposed to use it. I would point out however that those same intrinsics are listed in std.math (or at least some of them anyway - I haven't checked them all), meaning that Phobos assumes that the intrinsics exist, so either LDC expects the intrinsics and will blow up if you use them, it just doesn't have those functions in its version of Phobos, or it's providing its own implementations, since the standard Phobos doesn't provide implemenations for them. - Jonathan M Davis _______________________________________________ D-runtime mailing list D-runtime@puremagic.com http://lists.puremagic.com/mailman/listinfo/d-runtime |
October 02, 2012 Re: [D-runtime] Is core.math public API? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | On Tue, Oct 2, 2012 at 6:48 PM, Jonathan M Davis <jmdavisProg@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. David _______________________________________________ D-runtime mailing list D-runtime@puremagic.com http://lists.puremagic.com/mailman/listinfo/d-runtime |
October 02, 2012 Re: [D-runtime] Is core.math public API? | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Nadlinger | On Tuesday, October 02, 2012 19:43:52 David Nadlinger wrote: > > […] 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. No. I understood that. My point was that because std.math expects intrinsics for those funtions, if LDC _doesn't_ provide them, there will be issues, and they appear to be the same intrinsics that core.math expects, so if you need them for one, you need them for the other. But I'm not at all versed in the details of how the compiler(s) sort out the intrinsics themselves. - Jonathan M Davis _______________________________________________ D-runtime mailing list D-runtime@puremagic.com http://lists.puremagic.com/mailman/listinfo/d-runtime |
October 02, 2012 Re: [D-runtime] Is core.math public API? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alex Rønne Petersen | On Tue, Oct 2, 2012 at 6:45 PM, Alex Rønne Petersen <xtzgzorex@gmail.com> wrote: > It isn't. > > See: http://article.gmane.org/gmane.comp.lang.d.runtime/1187/match=core+math In my opinion, saying that something isn't part of the public druntime API, but at the same time is intended to be used from Phobos doesn't make much sense. After all, the whole point behind druntime (well, one of them) was to introduce a low-level abstraction layer so that Phobos could just be a library like any other. If Phobos ends up calling undocumented, private functions, "like any other" is definitely not true. Why would Phobos be allowed to call core.math functions, but not Tango or any other library? Anyway, currently std.math does not use core.math, but declares a few magic functions which are name-matched by DMD (the only remaining ones in std.*, by the way). This forces us to edit that file in the LDC copy of Phobos, because our intrinsics system works differently. So, would anyone object if I modify std.math to forward the functions to core.math instead, and add the latter to the public docs? Judging from Don's message linked by Alex, this was the original intention behind core.math anyway, and would remove one compiler dependency from Phobos, which is imho a desirable goal. Of course, I'd also extend the core.math docs with a short note mentioning that it only provides low-level intrinsics and std.math is to be preferred for actual application use. David _______________________________________________ D-runtime mailing list D-runtime@puremagic.com http://lists.puremagic.com/mailman/listinfo/d-runtime |
October 03, 2012 Re: [D-runtime] Is core.math public API? | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Nadlinger | On Tue, Oct 2, 2012 at 8:44 PM, David Nadlinger <code@klickverbot.at> wrote: > On Tue, Oct 2, 2012 at 6:45 PM, Alex Rønne Petersen <xtzgzorex@gmail.com> wrote: >> It isn't. >> >> See: http://article.gmane.org/gmane.comp.lang.d.runtime/1187/match=core+math > > In my opinion, saying that something isn't part of the public druntime API, but at the same time is intended to be used from Phobos doesn't make much sense. After all, the whole point behind druntime (well, one of them) was to introduce a low-level abstraction layer so that Phobos could just be a library like any other. If Phobos ends up calling undocumented, private functions, "like any other" is definitely not true. Why would Phobos be allowed to call core.math functions, but not Tango or any other library? > > Anyway, currently std.math does not use core.math, but declares a few magic functions which are name-matched by DMD (the only remaining ones in std.*, by the way). This forces us to edit that file in the LDC copy of Phobos, because our intrinsics system works differently. > > So, would anyone object if I modify std.math to forward the functions to core.math instead, and add the latter to the public docs? Judging from Don's message linked by Alex, this was the original intention behind core.math anyway, and would remove one compiler dependency from Phobos, which is imho a desirable goal. Of course, I'd also extend the core.math docs with a short note mentioning that it only provides low-level intrinsics and std.math is to be preferred for actual application use. I think this is perfectly reasonable - we need to eliminate any and all magic support the compiler has for things in Phobos. It must be another library or we have serious language design issues. Regards, Alex _______________________________________________ D-runtime mailing list D-runtime@puremagic.com http://lists.puremagic.com/mailman/listinfo/d-runtime |
October 03, 2012 Re: [D-runtime] Is core.math public API? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alex Rønne Petersen | On Wednesday, October 03, 2012 01:51:36 Alex Rønne Petersen wrote: > I think this is perfectly reasonable - we need to eliminate any and all magic support the compiler has for things in Phobos. It must be another library or we have serious language design issues. Well, pretty much the whole reason that druntime exists in the first place is so that the language stuff that requires code outside the compiler would be separated from the actual standard library code. So, it does seem like it's going contrary to that goal to make Phobos rely on magic support to do its thing. Certainly, if you can't build the exact same version of Phobos on two D compilers which are both compliant to the spec, then we have a problem. - Jonathan M Davis _______________________________________________ D-runtime mailing list D-runtime@puremagic.com http://lists.puremagic.com/mailman/listinfo/d-runtime |
October 03, 2012 Re: [D-runtime] Is core.math public API? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | On Oct 2, 2012, at 4:59 PM, Jonathan M Davis <jmdavisProg@gmx.com> wrote: > On Wednesday, October 03, 2012 01:51:36 Alex Rønne Petersen wrote: >> I think this is perfectly reasonable - we need to eliminate any and all magic support the compiler has for things in Phobos. It must be another library or we have serious language design issues. > > Well, pretty much the whole reason that druntime exists in the first place is so that the language stuff that requires code outside the compiler would be separated from the actual standard library code. So, it does seem like it's going contrary to that goal to make Phobos rely on magic support to do its thing. Certainly, if you can't build the exact same version of Phobos on two D compilers which are both compliant to the spec, then we have a problem. I think core.math can be labeled as experimental, and should either be sorted out or removed before too terribly long. Anything not in a ".internal" package should be considered callable by anyone, not just Phobos. With all the usual druntime caveats of course. _______________________________________________ D-runtime mailing list D-runtime@puremagic.com http://lists.puremagic.com/mailman/listinfo/d-runtime |
October 06, 2012 Re: [D-runtime] Is core.math public API? | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Nadlinger | On Tue, Oct 2, 2012 at 8:44 PM, David Nadlinger <code@klickverbot.at> wrote: > So, would anyone object if I modify std.math to forward the functions to core.math instead, and add the latter to the public docs? Hm, the only question is whether I should add function bodies calling the core.math functions, or use aliases to the core.math ones. The latter would have the advantage that no superfluous function call is generated even in debug mode, but I'm not sure how important that is, or if it's outweighed by the possible confusion an alias would cause (also, I'd probably have to use version (StdDdoc) blocks to not ruin the documentation with aliases). Thoughts? David _______________________________________________ D-runtime mailing list D-runtime@puremagic.com http://lists.puremagic.com/mailman/listinfo/d-runtime |
Copyright © 1999-2021 by the D Language Foundation