Re: [swift-evolution] [Idea] Add `bounds` function to standard library

2016-08-31 Thread Dominik Pich via swift-evolution
I agree with karl. there is nothing really mathematical with min/max e.g. find the longest sequence of characters in a string or the smallest array or the minimal x coordinate of view objects… min/max/clamp are needed everywhere. LG Dominik Web: https://pich.info Twitter: @DaijDjan Facebook: Do

Re: [swift-evolution] PITCH: Return a subclass for a protocol method without the need for an associatedtype

2016-08-31 Thread Karl via swift-evolution
> On 31 Aug 2016, at 06:10, Sitton, Yogev via swift-evolution > wrote: > > That’s was my point. > Two sets of rules for the same case in two different places. > These should be unified. > > I’ll write the proposal and create a pull request. > >> On Aug 17, 2016, at 11:24 PM, Slava Pestov >

Re: [swift-evolution] [PITCH] Add Ability To Specify Error Type On Throws

2016-08-31 Thread Chris Lattner via swift-evolution
> On Aug 30, 2016, at 3:54 PM, Mark Robinson via swift-evolution > wrote: > > Hello, > > Consider the scenario of the vending machine example in the Swift Book: Please catch up on the thread earlier this week on this exact topic. -Chris ___ swift-e

Re: [swift-evolution] Passing an optional first argument to sequence(first:next:)

2016-08-31 Thread Max Moiseev via swift-evolution
Right… Good catch! > On Aug 31, 2016, at 9:45 AM, Pyry Jahkola wrote: > > >> Max Moiseev wrote: >> >> FWIW, the ‘classical’ way of doing what I think you’re trying to do is: >> >> extension Sequence { >> var pairs: AnySequence<(Iterator.Element, Iterator.Element)> { >> return AnySequence(zi

Re: [swift-evolution] PITCH: Return a subclass for a protocol method without the need for an associatedtype

2016-08-31 Thread Sitton, Yogev via swift-evolution
That’s was my point. Two sets of rules for the same case in two different places. These should be unified. I’ll write the proposal and create a pull request. On Aug 17, 2016, at 11:24 PM, Slava Pestov mailto:spes...@apple.com>> wrote: On Aug 17, 2016, at 10:18 AM, Vladimir.S via swift-evolutio

Re: [swift-evolution] [Idea] Add `bounds` function to standard library

2016-08-31 Thread Xiaodi Wu via swift-evolution
Comparable makes semantic guarantees about how values of conforming types might be ordered. You don't need `min` or `max` for that to be useful, since it's trivial to implement using comparison operators. Basic numeric types require compiler magic and thus belong in the standard library. Likewise,

Re: [swift-evolution] Passing an optional first argument to sequence(first:next:)

2016-08-31 Thread Tim Vermeulen via swift-evolution
That works, though it calls `next()` on an iterator twice as often as is necessary… Either way, it’s not that important. There are ways around not having an optional `first` parameter. When I brought it up I thought it was just an oversight, but now that it turns out it isn’t (and there are reas

Re: [swift-evolution] [Idea] Add `bounds` function to standard library

2016-08-31 Thread Karl via swift-evolution
> On 30 Aug 2016, at 10:18, Xiaodi Wu via swift-evolution > wrote: > > As an additive proposal, I don't think this would be in scope for the current > phase of Swift 4. > > Looking forward, though, I'm not sure this belongs in the standard library. > In general, my understanding is that Swif

Re: [swift-evolution] New feature request: syntactic sugar for "if let" scoped self assignment

2016-08-31 Thread Chris Lattner via swift-evolution
> On Aug 28, 2016, at 12:54 PM, Nicholas Exner via swift-evolution > wrote: > > Dear Swift Evolution Group Members, > Recently, as I was reviewing some code that I wrote, I was wondering > what the community’s thoughts are on the possible value of having a special > “if let” self-ass

Re: [swift-evolution] Passing an optional first argument to sequence(first:next:)

2016-08-31 Thread Pyry Jahkola via swift-evolution
> Max Moiseev wrote: > > FWIW, the ‘classical’ way of doing what I think you’re trying to do is: > > extension Sequence { > var pairs: AnySequence<(Iterator.Element, Iterator.Element)> { >return AnySequence(zip(self, self.dropFirst())) > } > } > > Does it have the right behavior? It does

Re: [swift-evolution] Passing an optional first argument to sequence(first:next:)

2016-08-31 Thread Max Moiseev via swift-evolution
FWIW, the ‘classical’ way of doing what I think you’re trying to do is: extension Sequence { var pairs: AnySequence<(Iterator.Element, Iterator.Element)> { return AnySequence(zip(self, self.dropFirst())) } } Does it have the right behavior? Max > On Aug 29, 2016, at 9:45 AM, Tim Vermeul

[swift-evolution] [PITCH] Add Ability To Specify Error Type On Throws

2016-08-31 Thread Mark Robinson via swift-evolution
Hello, Consider the scenario of the vending machine example in the Swift Book: We have a function that throws errors from a single given ErrorType 1. func vend(itemNamed name: String) throws { 2. guard let item = inventory[name] else { 3. throw VendingMachineError.InvalidSelection 4