[swift-evolution] [Proposal draft] Enhanced floating-point protocols

Erica Sadun erica at ericasadun.com
Fri Apr 15 13:27:35 CDT 2016

> On Apr 15, 2016, at 12:22 PM, Stephen Canon <scanon at apple.com> wrote:
>> On Apr 15, 2016, at 11:14 AM, Erica Sadun <erica at ericasadun.com <mailto:erica at ericasadun.com>> wrote:
>> That said, I use M_PI_4 a lot because it's really handy for sample code. I'm one of the
>> outlier users whose use is not reflective of this quick check.
> M_PI_2 and M_PI_4 are interesting cases; they date back to a time when compilers couldn’t be trusted to constant-fold computations like M_PI / 2.  Since Swift quite reliably does this transformation, I would prefer to simply use the more explicit .pi / 2.  How does that strike you as a user?
> – Steve

I cannot really defend my use other than to say they are comfortable constants, ones that I read easily. 
Should Swift eliminate them I do not believe my code would suffer beyond muscle memory. Newer 
users don't necessarily resonate to them the same way, either.

I do think that adding both .pi and .π and using .π/4.0 would be the most readable expression of intent.

-- E

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160415/a0fbe4b4/attachment.html>

More information about the swift-evolution mailing list