-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Math functions for Swift #23140
Math functions for Swift #23140
Conversation
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please test |
Build failed |
Build failed |
@swift-ci clean test |
@stephentyrone @airspeedswift what is preventing this from moving forward? |
Build failed |
@tkremenek Just shaking out fallout from dropping the Math module, specifically what that means for the existing Platform functions. I expect to push this forward today. More precisely: when we had the Math module, it was possible for Platform to reexport it and preserve source compatibility while obsoleting the existing functions. That isn't possible any longer unless we have it reexport all of the stdlib, which seems like a bad idea. So I'm working on making the minimally invasive change to preserve the behavior of the platform module as much as possible while obsoleting a few specific functions as necessary to resolve ambiguities. This has turned out to be a bit fussier than I originally anticipated. |
Build failed |
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please test |
Build failed |
Build failed |
Fundamental decision to be made; should implementation hooks present like `Float.exp(_ x: Float) -> Float` or like `Float.Maths.exp(_ x: Float) -> Float`? Having the intermediate namespace to group them as in the second is definitely nicer, but it requires a little bit of extra machinery, and much more importantly, there doesn't seem to be any way to make access to the static `Maths` associatedtype transparent.
This reverts commit d9dde28.
This commit implements SE-0246, by adding conformance to Real to the Float, CGFloat, Double, and Float80 types, implemented either in terms of the system's C math library, existing standard library functionality, or LLVM intrinsics. It includes basic test coverage for these new functions, and deprecates and obsoletes *some* existing functionality in the Platform overlay. We still need to make a decision about how to handle the remaining "tgmath" functions, because obsoleting them is technically a source-breaking change (if users have unqualified names like "exp(1)", it's fine, but it would break users who have used qualified names like "Darwin.exp(1)".)
Build failed |
Build failed |
@swift-ci clean test |
Build failed |
Build failed |
@swift-ci please smoke test |
@swift-ci please test. |
Build failed |
Build failed |
@swift-ci please test. |
Build failed |
Build failed |
This broke the windows build! https://dev.azure.com/compnerd/windows-swift/_build/results?buildId=976 |
@compnerd windows doesn't have |
@stephentyrone - clearly MSVCRT hates math :-(
I think it may be inlined or something, since they claim it is in the library: |
@compnerd Can you replace _swift_stdlib_hypotf with a bogus stub on a branch and see if anything else breaks? You might also be able to call |
Yeah, guess we need to switch it over to
I'll put up a patch momentarily. |
/// ``` | ||
/// | ||
/// All of these are made available as free functions by importing the Math | ||
/// module: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is outdated, I thought?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I still need to update some comments.
* Revert "Merge pull request #23791 from compnerd/you-know-nothing-clang" This reverts commit 5150981, reversing changes made to 8fc305c. * Revert "Merge pull request #23780 from compnerd/math-is-terrible" This reverts commit 2d7fedd, reversing changes made to 0205150. * Revert "Merge pull request #23140 from stephentyrone/mafs" This reverts commit 777750d, reversing changes made to 0c8920e.
This PR implements SE-0246.
We still need to make a decision about how to handle obsoleting functions provided by the platform module. Because most programs pull in Foundation, they transitively pull in the existing names, which means that most functions calls in concrete contexts will get the tgmath functions, not the stdlib implementations. That's OK, but there are a few functions for which the behavior differs for edge cases (most notably
pow
), and we'd also like to remove these to cut down the overload sets.rdar://problem/17625344