Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-18 Thread Quinn "The Eskimo!" via swift-users
On 18 Sep 2017, at 13:52, Vladimir.S wrote: > Can't understand/accept this, sorry. You seem to be very invested in how Swift /should/ work, rather than how it /does/ work. I’m sympathetic with that position but it’s really a topic of conversation for swift-evolution rather

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-18 Thread Vladimir.S via swift-users
On 17.09.2017 13:25, Quinn "The Eskimo!" via swift-users wrote: On 15 Sep 2017, at 21:35, Vladimir.S via swift-users wrote: … for me it is very strange decision to disallow a method because it is 'expensive'. That’s pretty normal for Swift standard library

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-18 Thread Geordie Jay via swift-users
It seems to me that some of these concerns could be fixed by returning ArraySlice instead of Array on popFirst(). Then you’d have similar performance expectations and explicit copying like with String / Substring. Geordie Elia Cereda via swift-users schrieb am Mo. 18.

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-18 Thread Elia Cereda via swift-users
NSMutableArray does provide O(1) insertion and removal from the start and the end of the array (http://ciechanowski.me/blog/2014/03/05/exposing-nsmutablearray/). I think the reason Swift doesn't use this design is because it stores the data in a contiguous block of memory. Elia Cereda > Il

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-17 Thread Jon Shier via swift-users
Yes, it seems to fly in the face of protocols as they exist in Swift at the moment. Given the inability of protocols to guarantee performance characteristics, breaking conformant types like this seems like a bad way to try and fulfill a separate axis of concern. Wouldn’t a better idea

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-17 Thread Rick Mann via swift-users
> On Sep 17, 2017, at 03:25 , Quinn The Eskimo! via swift-users > wrote: > > > On 15 Sep 2017, at 21:35, Vladimir.S via swift-users > wrote: > >> … for me it is very strange decision to disallow a method because it is >> 'expensive'. > >

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-17 Thread Quinn "The Eskimo!" via swift-users
On 15 Sep 2017, at 21:35, Vladimir.S via swift-users wrote: > … for me it is very strange decision to disallow a method because it is > 'expensive'. That’s pretty normal for Swift standard library protocols, which define not just the behaviour of the routine but

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-15 Thread Rick Mann via swift-users
In my case, it's my own implementation of popFirst(), so I'm not sure why it's complaining at all. Who cares if it's slow? The declaration is identical to popLast(), with the exception that I'm defining mine in an extension that's not Generic (I don't know if you can do it any other way). But

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-15 Thread Vladimir.S via swift-users
On 14.09.2017 22:02, Jon Shier via swift-users wrote: Looks like this is sort of tracked in SR-5515popFirst error message is silly . I’m not sure what a good answer is here, since it seems like it isn’t supposed to be available if it can’t guarantee O(1)

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-15 Thread Rick Mann via swift-users
I meant to add: I implemented it based on the declaration of popLast(). > On Sep 15, 2017, at 13:05 , Roderick Mann via swift-users > wrote: > > >> On Sep 13, 2017, at 18:59 , Jon Shier wrote: >> >> I think there’s something strange with

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-15 Thread Roderick Mann via swift-users
> On Sep 13, 2017, at 18:59 , Jon Shier wrote: > > I think there’s something strange with popFirst. It doesn’t show up in > the autocomplete in Xcode, but it compiles, and popLast doesn’t throw the > same error. removeFirst doesn’t either, though it’s unsafe. Weird.

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-14 Thread Jon Shier via swift-users
Looks like this is sort of tracked in  SR-5515popFirst error message is silly . I’m not sure what a good answer is here, since it seems like it isn’t supposed to be available if it can’t guarantee O(1) behavior. Still seems like Array should have

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-14 Thread Jon Shier via swift-users
This seems oddly similar to https://bugs.swift.org/browse/SR-5659, but [Thing] should meet the appropriate criteria for popFirst to work properly. Yet the error we’re seeing here is the same that was originally seen when trying to use popFirst on a String. Definitely feels like some

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-14 Thread Jon Shier via swift-users
It also doesn’t explain why removeFirst would work but popFirst doesn’t. The mutation to the underlying array should be the same, the only different is that one returns the element optionally. It also doesn’t explain why popFirst doesn’t show up I the autocomplete but compiles anyway.

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-14 Thread Vladimir.S via swift-users
On 14.09.2017 11:14, Quinn "The Eskimo!" via swift-users wrote: On 14 Sep 2017, at 03:56, somu subscribe via swift-users wrote: popFirst is not available in the Array … Right. This makes sense when you consider the standard setup for an array, namely, a variable

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-14 Thread Quinn "The Eskimo!" via swift-users
On 14 Sep 2017, at 03:56, somu subscribe via swift-users wrote: > popFirst is not available in the Array … Right. This makes sense when you consider the standard setup for an array, namely, a variable length buffer of items. Removing the first element is expensive,

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-13 Thread somu subscribe via swift-users
Not sure why it is happening, but given below are my observations: Simplified version: var array = [1, 2, 3, 4, 5] _ = array.popFirst() //error: cannot use mutating member on immutable value: 'array' is immutable _ = array.popLast() //works ok popFirst is not available in the Array

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-13 Thread Jon Shier via swift-users
I think there’s something strange with popFirst. It doesn’t show up in the autocomplete in Xcode, but it compiles, and popLast doesn’t throw the same error. removeFirst doesn’t either, though it’s unsafe. Weird. Jon > On Sep 13, 2017, at 9:47 PM, Zhao Xin via swift-users

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-13 Thread Zhao Xin via swift-users
I begin to think it is related to how you `popFirst()` implemented. Check it or post it here. Zhao Xin On Thu, Sep 14, 2017 at 9:36 AM, Roderick Mann wrote: > Yeah, that's not it. I made the change you suggested, I get the same error. > > > On Sep 13, 2017, at 18:11 ,

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-13 Thread Roderick Mann via swift-users
Yeah, that's not it. I made the change you suggested, I get the same error. > On Sep 13, 2017, at 18:11 , Zhao Xin wrote: > > Change `self` to `ModelFetcher`. You are calling a class static property, not > a class instance property. > > Zhao Xin > > On Thu, Sep 14, 2017 at

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-13 Thread Roderick Mann via swift-users
Did this change in Swift 4? I like being able to refer to the class in a class func as "self". If I ever change the name of the class, or refactor the code, or something, I don't have to change it in a bunch of places. > On Sep 13, 2017, at 18:11 , Zhao Xin wrote: > >

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-13 Thread Roderick Mann via swift-users
Also, it works fine at a couple of other call sites. Why is this one special? > On Sep 13, 2017, at 18:11 , Zhao Xin wrote: > > Change `self` to `ModelFetcher`. You are calling a class static property, not > a class instance property. > > Zhao Xin > > On Thu, Sep 14, 2017