Re: [swift-evolution] FloatingPoint does not conform to ExpressibleByFloatLiteral

2018-01-17 Thread Xiaodi Wu via swift-evolution
On Wed, Jan 17, 2018 at 4:56 PM, Jonathan Hull via swift-evolution < swift-evolution@swift.org> wrote: > I’m with Nevin on this one. Perhaps the easiest thing to do is to add > something to the FloatLiteral type that lets you get it as a string if > desired. > > Didn’t we have a discussion a

Re: [swift-evolution] FloatingPoint does not conform to ExpressibleByFloatLiteral

2018-01-17 Thread Jonathan Hull via swift-evolution
I’m with Nevin on this one. Perhaps the easiest thing to do is to add something to the FloatLiteral type that lets you get it as a string if desired. Didn’t we have a discussion a while back on how to make Integer Literals work with BigInt? Maybe there is an idea from that discussion that

Re: [swift-evolution] FloatingPoint does not conform to ExpressibleByFloatLiteral

2018-01-16 Thread Xiaodi Wu via swift-evolution
On Tue, Jan 16, 2018 at 6:20 PM, Nevin Brackett-Rozinsky < nevin.brackettrozin...@gmail.com> wrote: > On Tue, Jan 16, 2018 at 6:31 PM, Xiaodi Wu wrote: > >> On Tue, Jan 16, 2018 at 4:30 PM, Nevin Brackett-Rozinsky < >> nevin.brackettrozin...@gmail.com> wrote: >> >>> The

Re: [swift-evolution] FloatingPoint does not conform to ExpressibleByFloatLiteral

2018-01-16 Thread Nevin Brackett-Rozinsky via swift-evolution
On Tue, Jan 16, 2018 at 6:31 PM, Xiaodi Wu wrote: > On Tue, Jan 16, 2018 at 4:30 PM, Nevin Brackett-Rozinsky < > nevin.brackettrozin...@gmail.com> wrote: > >> The thing that is “broken” here is generic programming. If I constrain >> something to FloatingPoint, I cannot use a

Re: [swift-evolution] FloatingPoint does not conform to ExpressibleByFloatLiteral

2018-01-16 Thread Rick Mann via swift-evolution
> On Jan 16, 2018, at 15:32 , Xiaodi Wu via swift-evolution > wrote: > > On Jan 16, 2018, at 14:30 , Nevin Brackett-Rozinsky via swift-evolution > wrote: >> >> That only works for numbers which don’t overflow the integer literals >>

Re: [swift-evolution] FloatingPoint does not conform to ExpressibleByFloatLiteral

2018-01-16 Thread Xiaodi Wu via swift-evolution
On Tue, Jan 16, 2018 at 4:30 PM, Nevin Brackett-Rozinsky < nevin.brackettrozin...@gmail.com> wrote: > The thing that is “broken” here is generic programming. If I constrain > something to FloatingPoint, I cannot use a float literal in calculations > with it: > > func centimeters (inches: T) -> T

Re: [swift-evolution] FloatingPoint does not conform to ExpressibleByFloatLiteral

2018-01-16 Thread Nevin Brackett-Rozinsky via swift-evolution
The thing that is “broken” here is generic programming. If I constrain something to FloatingPoint, I cannot use a float literal in calculations with it: func centimeters (inches: T) -> T { return 2.54 * inches// Error } Of course, “T: FloatingPoint” is an overconstraint in this

Re: [swift-evolution] FloatingPoint does not conform to ExpressibleByFloatLiteral

2018-01-16 Thread Chris Lattner via swift-evolution
On Jan 15, 2018, at 11:01 PM, Xiaodi Wu via swift-evolution wrote: > - Can we change the semantics? Maybe, but I doubt ExpressibleByFloatLiteral > can be outright replaced. You're not the first to wonder about how to design > an alternative protocol. Dig through the

Re: [swift-evolution] FloatingPoint does not conform to ExpressibleByFloatLiteral

2018-01-15 Thread Xiaodi Wu via swift-evolution
On Tue, Jan 16, 2018 at 00:32 Nevin Brackett-Rozinsky < nevin.brackettrozin...@gmail.com> wrote: > On Mon, Jan 15, 2018 at 11:27 PM, Xiaodi Wu wrote: > >> On Mon, Jan 15, 2018 at 20:37 Nevin Brackett-Rozinsky < >> nevin.brackettrozin...@gmail.com> wrote: >> >>> >>> That

Re: [swift-evolution] FloatingPoint does not conform to ExpressibleByFloatLiteral

2018-01-15 Thread Nevin Brackett-Rozinsky via swift-evolution
On Mon, Jan 15, 2018 at 11:27 PM, Xiaodi Wu wrote: > On Mon, Jan 15, 2018 at 20:37 Nevin Brackett-Rozinsky < > nevin.brackettrozin...@gmail.com> wrote: > >> >> That protocol is spelled ExpressibleByFloatLiteral, which reflects the >> meaning that we want and should have. The

Re: [swift-evolution] FloatingPoint does not conform to ExpressibleByFloatLiteral

2018-01-15 Thread Xiaodi Wu via swift-evolution
On Mon, Jan 15, 2018 at 20:37 Nevin Brackett-Rozinsky < nevin.brackettrozin...@gmail.com> wrote: > On Mon, Jan 15, 2018 at 8:51 PM, Xiaodi Wu wrote: > >> On Mon, Jan 15, 2018 at 19:20 Nevin Brackett-Rozinsky < >> nevin.brackettrozin...@gmail.com> wrote: >> >>> All I’m saying

Re: [swift-evolution] FloatingPoint does not conform to ExpressibleByFloatLiteral

2018-01-15 Thread Nevin Brackett-Rozinsky via swift-evolution
On Mon, Jan 15, 2018 at 8:51 PM, Xiaodi Wu wrote: > On Mon, Jan 15, 2018 at 19:20 Nevin Brackett-Rozinsky < > nevin.brackettrozin...@gmail.com> wrote: > >> All I’m saying is the current situation seems semantically wrong. As in, >> how can a type claim to be a floating point

Re: [swift-evolution] FloatingPoint does not conform to ExpressibleByFloatLiteral

2018-01-15 Thread Xiaodi Wu via swift-evolution
On Mon, Jan 15, 2018 at 19:20 Nevin Brackett-Rozinsky < nevin.brackettrozin...@gmail.com> wrote: > All I’m saying is the current situation seems semantically wrong. As in, > how can a type claim to be a floating point number, if it *literally* > cannot be represented by a floating point number? >

Re: [swift-evolution] FloatingPoint does not conform to ExpressibleByFloatLiteral

2018-01-15 Thread Nevin Brackett-Rozinsky via swift-evolution
All I’m saying is the current situation seems semantically wrong. As in, how can a type claim to be a floating point number, if it *literally* cannot be represented by a floating point number? You suggest treating a float literal as a string, but another alternative is to teach the compiler to

Re: [swift-evolution] FloatingPoint does not conform to ExpressibleByFloatLiteral

2018-01-15 Thread Xiaodi Wu via swift-evolution
On Mon, Jan 15, 2018 at 4:24 PM, Nevin Brackett-Rozinsky via swift-evolution wrote: > Currently, the FloatingPoint protocol does not conform to > ExpressibleByFloatLiteral, whereas BinaryFloatingPoint does. > > The only explanation I can find for this is a brief

[swift-evolution] FloatingPoint does not conform to ExpressibleByFloatLiteral

2018-01-15 Thread Nevin Brackett-Rozinsky via swift-evolution
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