A built-in Angle type

I'm curious to hear people's opinions on the idea of having an Angle type in the standard library. Concretely what I'm proposing is moving the Angle struct defined in SwiftUI down into the standard library. There are plenty of situations in which one might want to talk about angles without having any need to display them on the screen, and therefore without necessarily being in a context where SwiftUI is accessible. However, if I write code involving the Angle type, I would of course want it to be applicable in a visual context where I am using SwiftUI to display something related to these angles, and therefore I would not want SwiftUI to separately define its own type also named Angle - the ideal is that SwiftUI uses the built-in angle type. Are there reasons why this won't happen in the future/are there any specific reasons why it hasn't happened already?

1 Like

Swift Numerics issue #88 and pull request #169.

3 Likes

Related to angles, I was very disappointed to see tau get the short shrift in this other Swift Numerics thread Tau? · Issue #89 · apple/swift-numerics · GitHub. (tau = 2 pi, so that angle of a full circle can be expressed as 1 tau, 1/4 circle as 1/4 tau)

The question of Numerics also including a tau constant is met by an argument that left me wanting:

Q: should we include B as well as A
A: no, because using B instead of A in all cases is not ideal

I know the tau manifesto argues for replacing many uses of pi with tau, but Swift doesn't have to take a stand on that. Nobody would be asking Numerics to put tau in and take pi out.

2 Likes