Re: [swift-evolution] [swift-evolution-announce] [Review] SE-0080: Failable Numeric Conversion Initializers

2016-05-06 Thread Dave Abrahams via swift-evolution

on Wed May 04 2016, Colin Barrett  wrote:

>> Swift numeric types all currently have a family of conversion
> initializers. In many use cases they leave a lot to be
> desired. Initializing an integer type with a floating point value will
> truncate any fractional portion of the number. Initializing with an
> out-of-range value traps.
>
> Have you considered whether it makes sense to keep these around? Maybe
> the failable ones should be the default, and give the other ones a
> more descriptive 1st argument label.

That would overturn Swift's fundamental programming model for numerics,
which is based on the fact that, to a first approximation, everybody
codes, **and wants to continue coding** as though their Int is really an
unbounded integer and their Double is an unbounded real number with
unlimited precision.  We very intentionally make the limitations of our
numeric types observable, but also not in-your-face for basic operations.

If we were to go this route, we would also make you unwrap the result of
x + 1 because it might overflow.


-- 
Dave

___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] [swift-evolution-announce] [Review] SE-0080: Failable Numeric Conversion Initializers

2016-05-05 Thread Max Moiseev via swift-evolution
Hi Matthew,

In general, if you think there is something to be updated in the proposal, it 
is worth creating a new revision (like in the floating point protocols 
proposal, for example) and mentioning it in the thread.

I think it is a way to go in this particular case, since we are still in the 
first half of the review period. Any further discussion would benefit from it.

max


> On May 5, 2016, at 4:02 PM, Matthew Johnson  wrote:
> 
> 
> 
> Sent from my iPhone
> 
> On May 5, 2016, at 5:19 PM, Max Moiseev via swift-evolution 
> > wrote:
> 
>> Hi all,
>> 
>> This email is the result of a discussion between members of the standard 
>> library team.
>> 
>> We suggest changing the initializers argument label to `exactly` to match 
>> the one used in the floating point protocols proposal 
>> .
>>  Other than that the proposal seems to be a valuable addition to the 
>> standard library.
> 
> Thanks Max.  I'm glad to hear that!  Should I update the proposal or will you 
> just make that change as part of "accepted with modification"?
> 
>> 
>> max
>> 
>>> On May 3, 2016, at 8:57 PM, Chris Lattner >> > wrote:
>>> 
>>> Hello Swift community,
>>> 
>>> The review of "SE-0080: Failable Numeric Conversion Initializers" begins 
>>> now and runs through May 9. The proposal is available here:
>>> 
>>> 
>>> https://github.com/apple/swift-evolution/blob/master/proposals/0080-failable-numeric-initializers.md
>>>  
>>> 
>>> 
>>> Reviews are an important part of the Swift evolution process. All reviews 
>>> should be sent to the swift-evolution mailing list at
>>> 
>>> https://lists.swift.org/mailman/listinfo/swift-evolution 
>>> 
>>> 
>>> or, if you would like to keep your feedback private, directly to the review 
>>> manager.
>>> 
>>> What goes into a review?
>>> 
>>> The goal of the review process is to improve the proposal under review 
>>> through constructive criticism and contribute to the direction of Swift. 
>>> When writing your review, here are some questions you might want to answer 
>>> in your review:
>>> 
>>> * What is your evaluation of the proposal?
>>> * Is the problem being addressed significant enough to warrant a change 
>>> to Swift?
>>> * Does this proposal fit well with the feel and direction of Swift?
>>> * If you have used other languages or libraries with a similar feature, 
>>> how do you feel that this proposal compares to those?
>>> * How much effort did you put into your review? A glance, a quick 
>>> reading, or an in-depth study?
>>> 
>>> More information about the Swift evolution process is available at
>>> 
>>> https://github.com/apple/swift-evolution/blob/master/process.md 
>>> 
>>> 
>>> Thank you,
>>> 
>>> -Chris Lattner
>>> Review Manager
>>> 
>>> ___
>>> swift-evolution-announce mailing list
>>> swift-evolution-annou...@swift.org 
>>> 
>>> https://lists.swift.org/mailman/listinfo/swift-evolution-announce 
>>> 
>> 
>> ___
>> swift-evolution mailing list
>> swift-evolution@swift.org 
>> https://lists.swift.org/mailman/listinfo/swift-evolution 
>> 

___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] [swift-evolution-announce] [Review] SE-0080: Failable Numeric Conversion Initializers

2016-05-05 Thread Matthew Johnson via swift-evolution


Sent from my iPhone

> On May 5, 2016, at 5:19 PM, Max Moiseev via swift-evolution 
>  wrote:
> 
> Hi all,
> 
> This email is the result of a discussion between members of the standard 
> library team.
> 
> We suggest changing the initializers argument label to `exactly` to match the 
> one used in the floating point protocols proposal. Other than that the 
> proposal seems to be a valuable addition to the standard library.

Thanks Max.  I'm glad to hear that!  Should I update the proposal or will you 
just make that change as part of "accepted with modification"?

> 
> max
> 
>> On May 3, 2016, at 8:57 PM, Chris Lattner  wrote:
>> 
>> Hello Swift community,
>> 
>> The review of "SE-0080: Failable Numeric Conversion Initializers" begins now 
>> and runs through May 9. The proposal is available here:
>> 
>>  
>> https://github.com/apple/swift-evolution/blob/master/proposals/0080-failable-numeric-initializers.md
>> 
>> Reviews are an important part of the Swift evolution process. All reviews 
>> should be sent to the swift-evolution mailing list at
>> 
>>  https://lists.swift.org/mailman/listinfo/swift-evolution
>> 
>> or, if you would like to keep your feedback private, directly to the review 
>> manager.
>> 
>> What goes into a review?
>> 
>> The goal of the review process is to improve the proposal under review 
>> through constructive criticism and contribute to the direction of Swift. 
>> When writing your review, here are some questions you might want to answer 
>> in your review:
>> 
>>  * What is your evaluation of the proposal?
>>  * Is the problem being addressed significant enough to warrant a change 
>> to Swift?
>>  * Does this proposal fit well with the feel and direction of Swift?
>>  * If you have used other languages or libraries with a similar feature, 
>> how do you feel that this proposal compares to those?
>>  * How much effort did you put into your review? A glance, a quick 
>> reading, or an in-depth study?
>> 
>> More information about the Swift evolution process is available at
>> 
>>  https://github.com/apple/swift-evolution/blob/master/process.md
>> 
>> Thank you,
>> 
>> -Chris Lattner
>> Review Manager
>> 
>> ___
>> swift-evolution-announce mailing list
>> swift-evolution-annou...@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution-announce
> 
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] [swift-evolution-announce] [Review] SE-0080: Failable Numeric Conversion Initializers

2016-05-05 Thread Max Moiseev via swift-evolution
Hi all,

This email is the result of a discussion between members of the standard 
library team.

We suggest changing the initializers argument label to `exactly` to match the 
one used in the floating point protocols proposal 
.
 Other than that the proposal seems to be a valuable addition to the standard 
library.

max

> On May 3, 2016, at 8:57 PM, Chris Lattner  wrote:
> 
> Hello Swift community,
> 
> The review of "SE-0080: Failable Numeric Conversion Initializers" begins now 
> and runs through May 9. The proposal is available here:
> 
>   
> https://github.com/apple/swift-evolution/blob/master/proposals/0080-failable-numeric-initializers.md
> 
> Reviews are an important part of the Swift evolution process. All reviews 
> should be sent to the swift-evolution mailing list at
> 
>   https://lists.swift.org/mailman/listinfo/swift-evolution
> 
> or, if you would like to keep your feedback private, directly to the review 
> manager.
> 
> What goes into a review?
> 
> The goal of the review process is to improve the proposal under review 
> through constructive criticism and contribute to the direction of Swift. When 
> writing your review, here are some questions you might want to answer in your 
> review:
> 
>   * What is your evaluation of the proposal?
>   * Is the problem being addressed significant enough to warrant a change 
> to Swift?
>   * Does this proposal fit well with the feel and direction of Swift?
>   * If you have used other languages or libraries with a similar feature, 
> how do you feel that this proposal compares to those?
>   * How much effort did you put into your review? A glance, a quick 
> reading, or an in-depth study?
> 
> More information about the Swift evolution process is available at
> 
>   https://github.com/apple/swift-evolution/blob/master/process.md
> 
> Thank you,
> 
> -Chris Lattner
> Review Manager
> 
> ___
> swift-evolution-announce mailing list
> swift-evolution-annou...@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution-announce

___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] [swift-evolution-announce] [Review] SE-0080: Failable Numeric Conversion Initializers

2016-05-04 Thread Colin Barrett via swift-evolution
Thanks Matthew. Personally I would really like to see an analysis of the 
tradeoffs therein covered in the proposal in some way.

-Colin (via thumbs)

> On May 4, 2016, at 8:23 PM, Matthew Johnson  wrote:
> 
> 
>>> On May 4, 2016, at 6:56 PM, Colin Barrett via swift-evolution 
>>>  wrote:
>>> 
>>> Swift numeric types all currently have a family of conversion initializers. 
>>> In many use cases they leave a lot to be desired. Initializing an integer 
>>> type with a floating point value will truncate any fractional portion of 
>>> the number. Initializing with an out-of-range value traps.
>> 
>> 
>> Have you considered whether it makes sense to keep these around? Maybe the 
>> failable ones should be the default, and give the other ones a more 
>> descriptive 1st argument label.
> 
> That’s a good question.  It might be a good idea, but I wanted to keep this 
> proposal small and non-breaking to maximize chances of acceptance.  I would 
> support that change to the proposal if the core team was interested in going 
> that direction.
> 
>> 
>> -Colin
>> ___
>> swift-evolution mailing list
>> swift-evolution@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] [swift-evolution-announce] [Review] SE-0080: Failable Numeric Conversion Initializers

2016-05-04 Thread Matthew Johnson via swift-evolution

> On May 4, 2016, at 6:56 PM, Colin Barrett via swift-evolution 
>  wrote:
> 
>> Swift numeric types all currently have a family of conversion initializers. 
>> In many use cases they leave a lot to be desired. Initializing an integer 
>> type with a floating point value will truncate any fractional portion of the 
>> number. Initializing with an out-of-range value traps.
> 
> 
> Have you considered whether it makes sense to keep these around? Maybe the 
> failable ones should be the default, and give the other ones a more 
> descriptive 1st argument label.

That’s a good question.  It might be a good idea, but I wanted to keep this 
proposal small and non-breaking to maximize chances of acceptance.  I would 
support that change to the proposal if the core team was interested in going 
that direction.

> 
> -Colin
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] [swift-evolution-announce] [Review] SE-0080: Failable Numeric Conversion Initializers

2016-05-04 Thread Colin Barrett via swift-evolution
> Swift numeric types all currently have a family of conversion initializers. 
> In many use cases they leave a lot to be desired. Initializing an integer 
> type with a floating point value will truncate any fractional portion of the 
> number. Initializing with an out-of-range value traps.


Have you considered whether it makes sense to keep these around? Maybe the 
failable ones should be the default, and give the other ones a more descriptive 
1st argument label.

-Colin
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] [swift-evolution-announce] [Review] SE-0080: Failable Numeric Conversion Initializers

2016-05-04 Thread Stephen Canon via swift-evolution
First, a general +1 to these, thanks for proposing them.

In SE-0067 we spelled these “exactly” rather than “exact”.
init?(exactly value: Source)

As for –0, Int(exactly: -0.0) should *not* fail.  My rationale for this is as 
follows:

- While information (the signbit) is lost, the essential property is that 
`Double(Int(exactly: -0.0)) == -0.0`.
- If we instead adopted “no information loss” as a criteria, we would back 
ourselves into a corner w.r.t decimal floating-point types, which have multiple 
representations of most values (1.0 can be encoded as 1e0 or 10e-1 or 100e-2 
…).  The result would be that these initializers would always fail for decimal 
fp inputs.

– Steve___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution