[swift-evolution] FloatingPoint does not conform to ExpressibleByFloatLiteral

Nevin Brackett-Rozinsky nevin.brackettrozinsky at gmail.com
Mon Jan 15 16:24:45 CST 2018

Currently, the FloatingPoint protocol does not conform to
ExpressibleByFloatLiteral, whereas BinaryFloatingPoint does.

The only explanation I can find for this is a brief comment from Steve Canon
during the review of SE-0067 (Enhanced Floating Point Protocols)

On Mon, Apr 25, 2016 at 1:32 PM, Stephen Canon via swift-evolution
> <swift-evolution at swift.org> wrote:
> On Apr 23, 2016, at 8:53 PM, Brent Royal-Gordon via swift-evolution
>> <swift-evolution at swift.org> wrote:
>> Any reason why FloatLiteralConvertible isn't on FloatingPoint?
> It doesn’t make sense for non-radix-2 types; you would change bases
> multiple times.

I don’t have Steve’s level of floating-point expertise, but from a
conceptual standpoint Swift protocols encapsulate semantics and, unless I
am quite mistaken, semantically a floating-point number *can* be expressed
as a floating-point literal.

So, what exactly is the problem preventing such a conformance, and what
would be required to fix it? Do we need to revamp how numeric literals are
handled, eg. to allow arbitrary-precision integers and base-agnostic floats?

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

More information about the swift-evolution mailing list