Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-05 Thread Matthew Johnson via swift-evolution
> On May 5, 2016, at 2:51 PM, Dave Abrahams wrote: > > > on Thu May 05 2016, Matthew Johnson > wrote: > >> Sent from my iPad >> >>> On May 5, 2016, at 10:59 AM, Dave Abrahams wrote: >>> >>> >>> on Wed May 04 2016, Matthew Johnson wrote: >>> > On Ma

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-05 Thread Dave Abrahams via swift-evolution
on Thu May 05 2016, Joe Groff wrote: >> On May 5, 2016, at 10:03 AM, Dave Abrahams wrote: >> >> >> on Thu May 05 2016, Joe Groff wrote: >> > On May 5, 2016, at 8:56 AM, Dave Abrahams wrote: on Wed May 04 2016, Joe Groff wrote: >>> >> On May 4, 2016, at 5:2

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-05 Thread Dave Abrahams via swift-evolution
on Thu May 05 2016, Matthew Johnson wrote: > Sent from my iPad > >> On May 5, 2016, at 10:59 AM, Dave Abrahams wrote: >> >> >> on Wed May 04 2016, Matthew Johnson wrote: >> On May 4, 2016, at 4:16 PM, David Sweeris wrote: Having given it some more thought... Does "PureRefer

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-05 Thread Joe Groff via swift-evolution
> On May 5, 2016, at 10:03 AM, Dave Abrahams wrote: > > > on Thu May 05 2016, Joe Groff wrote: > >>> On May 5, 2016, at 8:56 AM, Dave Abrahams wrote: >>> >>> >>> on Wed May 04 2016, Joe Groff wrote: >>> >> > On May 4, 2016, at 5:28 AM, T.J. Usiyan via swift-evolution > wrote:

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-05 Thread Dave Abrahams via swift-evolution
on Thu May 05 2016, Joe Groff wrote: >> On May 5, 2016, at 8:56 AM, Dave Abrahams wrote: >> >> >> on Wed May 04 2016, Joe Groff wrote: >> > On May 4, 2016, at 5:28 AM, T.J. Usiyan via swift-evolution wrote: Something about your first paragraph reminded me of a questio

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-05 Thread Matthew Johnson via swift-evolution
> On May 5, 2016, at 11:06 AM, Joe Groff via swift-evolution > wrote: > >> >> On May 5, 2016, at 8:56 AM, Dave Abrahams wrote: >> >> >> on Wed May 04 2016, Joe Groff wrote: >> On May 4, 2016, at 5:28 AM, T.J. Usiyan via swift-evolution wrote: Something about your fi

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-05 Thread David Sweeris via swift-evolution
> On May 5, 2016, at 10:59 AM, Dave Abrahams wrote: > > > on Wed May 04 2016, Matthew Johnson wrote: > >>> On May 4, 2016, at 4:16 PM, David Sweeris wrote: >>> >>> Having given it some more thought... Does "PureReference" make >>> sense? What would it mean? At some point a reference has to,

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-05 Thread Matthew Johnson via swift-evolution
Sent from my iPad > On May 5, 2016, at 10:59 AM, Dave Abrahams wrote: > > > on Wed May 04 2016, Matthew Johnson wrote: > >>> On May 4, 2016, at 4:16 PM, David Sweeris wrote: >>> >>> Having given it some more thought... Does "PureReference" make >>> sense? What would it mean? At some point

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-05 Thread Dave Abrahams via swift-evolution
on Wed May 04 2016, Matthew Johnson wrote: >> On May 4, 2016, at 4:16 PM, David Sweeris wrote: >> >> Having given it some more thought... Does "PureReference" make >> sense? What would it mean? At some point a reference has to, you >> know, actually refer to a concrete value. Otherwise it's ju

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-05 Thread Joe Groff via swift-evolution
> On May 5, 2016, at 8:56 AM, Dave Abrahams wrote: > > > on Wed May 04 2016, Joe Groff wrote: > >>> On May 4, 2016, at 5:28 AM, T.J. Usiyan via swift-evolution >>> wrote: >>> >>> Something about your first paragraph reminded me of a question I've >>> had for a while. Is there a reasoning b

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-05 Thread Dave Abrahams via swift-evolution
on Wed May 04 2016, Joe Groff wrote: >> On May 4, 2016, at 5:28 AM, T.J. Usiyan via swift-evolution >> wrote: >> >> Something about your first paragraph reminded me of a question I've >> had for a while. Is there a reasoning behind not being able to >> restrict a protocol to value types? One

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-05 Thread Dave Abrahams via swift-evolution
on Wed May 04 2016, "T.J. Usiyan" wrote: > Something about your first paragraph reminded me of a question I've had for a > while. Is there a reasoning behind not being able to restrict a protocol to > value types? There are two answers: 1. We haven't gotten around to it 2. As I mentioned els

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-04 Thread Matthew Johnson via swift-evolution
> On May 4, 2016, at 4:16 PM, David Sweeris wrote: > > Having given it some more thought... Does "PureReference" make sense? What > would it mean? At some point a reference has to, you know, actually refer to > a concrete value. Otherwise it's just turtles all the way down. In my thinking Pur

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-04 Thread Matthew Johnson via swift-evolution
> On May 4, 2016, at 4:20 PM, David Sweeris wrote: > > ... And 30 seconds later I realized that "PureReference" could be fulfilled > by something with only static or computed properties. Any class that only had immutable value semantic members would fulfill PureReference. They would not need

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-04 Thread David Sweeris via swift-evolution
... And 30 seconds later I realized that "PureReference" could be fulfilled by something with only static or computed properties. Sent from my iPhone > On May 4, 2016, at 16:16, David Sweeris via swift-evolution > wrote: > > Having given it some more thought... Does "PureReference" make sens

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-04 Thread David Sweeris via swift-evolution
Having given it some more thought... Does "PureReference" make sense? What would it mean? At some point a reference has to, you know, actually refer to a concrete value. Otherwise it's just turtles all the way down. Sent from my iPhone > On May 4, 2016, at 13:32, Matthew Johnson wrote: > > >

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-04 Thread Matthew Johnson via swift-evolution
> On May 4, 2016, at 1:21 PM, David Sweeris via swift-evolution > wrote: > > >> On May 4, 2016, at 11:12, Joe Groff via swift-evolution >> wrote: >> >> I can see value in there being some kind of PureValue protocol, for types >> that represent fully self-contained values, but conforming to

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-04 Thread Joe Groff via swift-evolution
> On May 3, 2016, at 8:02 PM, Jordan Rose via swift-evolution > wrote: > > Dave and I have pondered this before, and considered that one possible > (drastic) solution is to ban classes from implementing protocols with > mutating members, on the grounds that it’s very hard to write an algorith

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-04 Thread David Sweeris via swift-evolution
> On May 4, 2016, at 11:12, Joe Groff via swift-evolution > wrote: > > I can see value in there being some kind of PureValue protocol, for types > that represent fully self-contained values, but conforming to that protocol > requires a bit more thought than just being a struct or enum, since

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-04 Thread Joe Groff via swift-evolution
> On May 4, 2016, at 5:28 AM, T.J. Usiyan via swift-evolution > wrote: > > Something about your first paragraph reminded me of a question I've had for a > while. Is there a reasoning behind not being able to restrict a protocol to > value types? One way that this might be workable is if we co

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-04 Thread James Froggatt via swift-evolution
Your comment on overloads for reference types gave me an idea. I've just tried in a playground, and overloading is currently possible for protocol extensions. Providing an implementation, then separate ones in an extension where Self: AnyObject, will cause the compiler to choose the more specifi

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-04 Thread Matthew Johnson via swift-evolution
Sent from my iPad > On May 4, 2016, at 7:28 AM, T.J. Usiyan via swift-evolution > wrote: > > Something about your first paragraph reminded me of a question I've had for a > while. Is there a reasoning behind not being able to restrict a protocol to > value types? One way that this might be

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-04 Thread T.J. Usiyan via swift-evolution
Something about your first paragraph reminded me of a question I've had for a while. Is there a reasoning behind not being able to restrict a protocol to value types? One way that this might be workable is if we could overload protocols for Value vs for reference. TJ On Tue, May 3, 2016 at 11:02

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-04 Thread James Froggatt via swift-evolution
Thanks. It's a shame this isn't being addressed. I find myself always considering whether things are value-type or reference-type when writing generic code, avoiding assignments to self for this reason, and feel bad adding mutating methods to protocols knowing that it will make the protocol almo

Re: [swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-03 Thread Jordan Rose via swift-evolution
Dave and I have pondered this before, and considered that one possible (drastic) solution is to ban classes from implementing protocols with mutating members, on the grounds that it’s very hard to write an algorithm that’s correct for both. func removing(_ element: Element) -> Self { var resu

[swift-evolution] [Oversight] Reference types allow mutating methods through generics

2016-05-03 Thread James Froggatt via swift-evolution
Thanks for the response, I agree this is currently the best solution. Unfortunately, it's not just as simple as just implementing each method, since without being able to call super, I have to fully reimplement the original behaviour, which at best seems like bad practice, and would break in fut