Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-19 Thread Brent Royal-Gordon via swift-evolution
> On Aug 16, 2016, at 6:51 PM, Slava Pestov via swift-evolution > wrote: > >> I am a little concerned about the second requirement. Protocols that include >> static methods and initializers work perfectly well inside arrays, and >> restricting them from generic collections will further discour

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-18 Thread Alexis Beingessner via swift-evolution
Slava and Joe's suggestion of self conformance and the constraints involved are something that's been explored in other languages with similar systems. There's a great series of posts discussing some of the issues at hand: These describe the constraints of interest (“object safety”): http://huo

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-17 Thread Vladimir.S via swift-evolution
Inline On 17.08.2016 21:36, Charles Srstka wrote: On Aug 17, 2016, at 12:02 PM, Vladimir.S via swift-evolution mailto:swift-evolution@swift.org>> wrote: On 17.08.2016 13:00, Boris Wang via swift-evolution wrote: The problem is that: protocol should not be a type, but it is a type sometime and

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-17 Thread Charles Srstka via swift-evolution
> On Aug 17, 2016, at 3:25 PM, Slava Pestov wrote: > > I’m not the Word of God, nor am I on the core team, I just work here and > stating my opinions on the matter ;-) Working at Apple is close enough. ;-) Charles___ swift-evolution mailing list swif

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-17 Thread Slava Pestov via swift-evolution
> On Aug 17, 2016, at 11:36 AM, Charles Srstka via swift-evolution > wrote: > >> On Aug 17, 2016, at 12:02 PM, Vladimir.S via swift-evolution >> mailto:swift-evolution@swift.org>> wrote: >> >> On 17.08.2016 13:00, Boris Wang via swift-evolution wrote: >>> The problem is that: >>> protocol sho

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-17 Thread Charles Srstka via swift-evolution
> On Aug 17, 2016, at 12:02 PM, Vladimir.S via swift-evolution > wrote: > > On 17.08.2016 13:00, Boris Wang via swift-evolution wrote: >> The problem is that: >> protocol should not be a type, but it is a type sometime and not type >> sometime now. >> >> for exam: >> P.Type not same as T.Type >

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-17 Thread Vladimir.S via swift-evolution
On 17.08.2016 13:00, Boris Wang via swift-evolution wrote: The problem is that: protocol should not be a type, but it is a type sometime and not type sometime now. for exam: P.Type not same as T.Type But you can declare a variable of type P. Protocol should be a contract only, no instances of

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-17 Thread Boris Wang via swift-evolution
The problem is that: protocol should not be a type, but it is a type sometime and not type sometime now. for exam: P.Type not same as T.Type But you can declare a variable of type P. Protocol should be a contract only, no instances of it. Charles Srstka via swift-evolution 于2016年8月17日 周三14:11写

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread Charles Srstka via swift-evolution
> On Aug 17, 2016, at 12:35 AM, Slava Pestov wrote: > > >> On Aug 16, 2016, at 10:16 PM, Charles Srstka > > wrote: >> >>> On Aug 16, 2016, at 11:42 PM, Slava Pestov >> > wrote: Argh, that’s particularly frustrating since in s

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread Slava Pestov via swift-evolution
> On Aug 16, 2016, at 10:16 PM, Charles Srstka wrote: > >> On Aug 16, 2016, at 11:42 PM, Slava Pestov > > wrote: >>> >>> Argh, that’s particularly frustrating since in something like ‘func foo>> P>(t: T)’ or ‘func foo(s: S) where S.IteratorElement: P’, >>> you’re only

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread Charles Srstka via swift-evolution
> On Aug 16, 2016, at 11:42 PM, Slava Pestov wrote: >> >> Argh, that’s particularly frustrating since in something like ‘func foo> P>(t: T)’ or ‘func foo(s: S) where S.IteratorElement: P’, >> you’re only ever getting instances anyway since the parameter is in the >> input, so calling initialize

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread Slava Pestov via swift-evolution
> On Aug 16, 2016, at 8:52 PM, Charles Srstka wrote: > >> On Aug 16, 2016, at 8:51 PM, Slava Pestov > > wrote: >> >> Here is why we must have that requirement. Consider the following code: >> >> protocol P { >> init() >> } >> >> struct A : P { >> init() {} >> } >

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread Charles Srstka via swift-evolution
> On Aug 16, 2016, at 8:51 PM, Slava Pestov wrote: > > Here is why we must have that requirement. Consider the following code: > > protocol P { > init() > } > > struct A : P { > init() {} > } > > struct B : P { > init() {} > } > > func makeIt() -> T { > return T() > } > > I can use t

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread Slava Pestov via swift-evolution
> On Aug 16, 2016, at 6:51 PM, Slava Pestov wrote: > >> >> On Aug 16, 2016, at 6:40 PM, Charles Srstka > > wrote: >> >>> On Aug 16, 2016, at 8:13 PM, Slava Pestov >> > wrote: >>> >>> -1 — this adds a new syntax with little gain, and p

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread Slava Pestov via swift-evolution
> On Aug 16, 2016, at 6:40 PM, Charles Srstka wrote: > >> On Aug 16, 2016, at 8:13 PM, Slava Pestov > > wrote: >> >> -1 — this adds a new syntax with little gain, and potentially a lot of >> additional complexity. >> >>> On Aug 16, 2016, at 2:49 PM, Charles Srstka vi

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread Charles Srstka via swift-evolution
> On Aug 16, 2016, at 8:13 PM, Slava Pestov wrote: > > -1 — this adds a new syntax with little gain, and potentially a lot of > additional complexity. > >> On Aug 16, 2016, at 2:49 PM, Charles Srstka via swift-evolution >> wrote: >> >> Unfortunately, when this has come up on the list in the

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread Slava Pestov via swift-evolution
> On Aug 16, 2016, at 6:05 PM, Charles Srstka via swift-evolution > wrote: > >> On Aug 16, 2016, at 7:48 PM, Xiaodi Wu > > wrote: >> >> On Tue, Aug 16, 2016 at 7:43 PM, Charles Srstka > > wrote: >>> On Aug 16, 2016, at 7:08 PM, Xiaod

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread Slava Pestov via swift-evolution
-1 — this adds a new syntax with little gain, and potentially a lot of additional complexity. > On Aug 16, 2016, at 2:49 PM, Charles Srstka via swift-evolution > wrote: > > Unfortunately, when this has come up on the list in the past, it has been > mentioned that there are some cases where an

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread Joe Groff via swift-evolution
> On Aug 16, 2016, at 2:49 PM, Charles Srstka via swift-evolution > wrote: > > MOTIVATION: > > Suppose we have a bunch of peppers, and we’d like to make a function to pick > them. We could just take an array, but Swift supports many types of sequence > types beyond a simple array, and it wou

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread Charles Srstka via swift-evolution
> On Aug 16, 2016, at 7:48 PM, Xiaodi Wu wrote: > > On Tue, Aug 16, 2016 at 7:43 PM, Charles Srstka > wrote: >> On Aug 16, 2016, at 7:08 PM, Xiaodi Wu > > wrote: >> >> On Tue, Aug 16, 2016 at 6:59 PM, Karl >

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread Xiaodi Wu via swift-evolution
On Tue, Aug 16, 2016 at 7:43 PM, Charles Srstka wrote: > On Aug 16, 2016, at 7:08 PM, Xiaodi Wu wrote: > > > On Tue, Aug 16, 2016 at 6:59 PM, Karl wrote: > >> >> On 17 Aug 2016, at 00:34, Charles Srstka via swift-evolution < >> swift-evolution@swift.org> wrote: >> >> On Aug 16, 2016, at 5:30 PM

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread Charles Srstka via swift-evolution
> On Aug 16, 2016, at 7:08 PM, Xiaodi Wu wrote: > > On Tue, Aug 16, 2016 at 6:59 PM, Karl > wrote: > >> On 17 Aug 2016, at 00:34, Charles Srstka via swift-evolution >> mailto:swift-evolution@swift.org>> wrote: >> >>> On Aug 16, 2016, at 5:30 PM, Xiaodi Wu >>

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread David Sweeris via swift-evolution
> On Aug 16, 2016, at 6:59 PM, Karl via swift-evolution > wrote: > > I think the point is that existentials not conforming to their protocols is > the underlying reason this doesn’t work already. > > From the previous thread: >> There are a couple of reasons this is the case. IIRC in some cas

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread Xiaodi Wu via swift-evolution
On Tue, Aug 16, 2016 at 6:59 PM, Karl wrote: > > On 17 Aug 2016, at 00:34, Charles Srstka via swift-evolution < > swift-evolution@swift.org> wrote: > > On Aug 16, 2016, at 5:30 PM, Xiaodi Wu wrote: > > > On Tue, Aug 16, 2016 at 5:19 PM, Charles Srstka via swift-evolution < > swift-evolution@swif

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread Karl via swift-evolution
> On 17 Aug 2016, at 00:34, Charles Srstka via swift-evolution > wrote: > >> On Aug 16, 2016, at 5:30 PM, Xiaodi Wu > > wrote: >> >> On Tue, Aug 16, 2016 at 5:19 PM, Charles Srstka via swift-evolution >> mailto:swift-evolution@swift.org>> wrote: >>> On Aug 16, 2016

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread Charles Srstka via swift-evolution
> On Aug 16, 2016, at 5:30 PM, Xiaodi Wu wrote: > > On Tue, Aug 16, 2016 at 5:19 PM, Charles Srstka via swift-evolution > mailto:swift-evolution@swift.org>> wrote: >> On Aug 16, 2016, at 5:13 PM, David Sweeris > > wrote: >> >> Any proposal that expands the power of g

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread Xiaodi Wu via swift-evolution
On Tue, Aug 16, 2016 at 5:19 PM, Charles Srstka via swift-evolution < swift-evolution@swift.org> wrote: > On Aug 16, 2016, at 5:13 PM, David Sweeris wrote: > > > Any proposal that expands the power of generic programming gets an almost > automatic +1 from me. > > I can't think of any circumstance

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread Charles Srstka via swift-evolution
> On Aug 16, 2016, at 5:13 PM, David Sweeris wrote: > > Any proposal that expands the power of generic programming gets an almost > automatic +1 from me. > > I can't think of any circumstances in which I wouldn't want to use ":==" > instead of ":". Are there any downsides to expanding ":" to m

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread David Sweeris via swift-evolution
Any proposal that expands the power of generic programming gets an almost automatic +1 from me. I can't think of any circumstances in which I wouldn't want to use ":==" instead of ":". Are there any downsides to expanding ":" to mean what ":==" does? Incidentally, I kinda thought things either

Re: [swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread Daniel Resnick via swift-evolution
It's weird to me that protocol-typed objects aren't seen as conforming to that protocol. I would intuitively expect this function to work for both a sequence of Pepper types and other types that conform to Pepper: func pick(peppers: PepperType) where PepperType.Iterator.Element: Pepper { // pic

[swift-evolution] PITCH: New :== operator for generic constraints

2016-08-16 Thread Charles Srstka via swift-evolution
MOTIVATION: Suppose we have a bunch of peppers, and we’d like to make a function to pick them. We could just take an array, but Swift supports many types of sequence types beyond a simple array, and it would be nice to support those as well, particularly since we have this one client who stores