Re: [swift-users] Problem with mutable views and COW

2016-11-18 Thread John McCall via swift-users
> On Nov 18, 2016, at 3:10 PM, Karl wrote: > > >> On 18 Nov 2016, at 20:18, John McCall > > wrote: >> >>> >>> On Nov 18, 2016, at 7:40 AM, Karl >> > wrote: >>> >>> On

Re: [swift-users] Problem with mutable views and COW

2016-11-18 Thread Karl via swift-users
> On 18 Nov 2016, at 20:18, John McCall wrote: > >> >> On Nov 18, 2016, at 7:40 AM, Karl > > wrote: >> >> >>> On 18 Nov 2016, at 13:05, Adrian Zubarev via swift-users >>>

Re: [swift-users] Problem with mutable views and COW

2016-11-18 Thread John McCall via swift-users
> On Nov 18, 2016, at 7:40 AM, Karl wrote: > > >> On 18 Nov 2016, at 13:05, Adrian Zubarev via swift-users >> > wrote: >> >> Hi there, >> >> I just can’t get my head around mutable views and COW. >> >> Here is a small

Re: [swift-users] Problem with mutable views and COW

2016-11-18 Thread Adrian Zubarev via swift-users
What exactly to you mean by unsafe/invalide? If you refer to unowned than yes this is incorrect. That was only part of the first question about isKnownUniquelyReferenced, where I myself missed the part from the docs that says that weak references don’t affect the result. In general

Re: [swift-users] Problem with mutable views and COW

2016-11-18 Thread Karl via swift-users
> On 18 Nov 2016, at 13:05, Adrian Zubarev via swift-users > wrote: > > Hi there, > > I just can’t get my head around mutable views and COW. > > Here is a small example: > > final class Storage { > > var keys: [String] = [] > var values: [Int] = [] > } >

Re: [swift-users] Problem with mutable views and COW

2016-11-18 Thread Adrian Zubarev via swift-users
Nah it’s okay mate. ;) This is the right list, because I ask for help. COW stands for copy-on-write. If you’re interesting on learning something new, read this paragraph

Re: [swift-users] Problem with mutable views and COW

2016-11-18 Thread Zhao Xin via swift-users
protocol Copyable { func copy() -> Self } final class Storage:Copyable { var keys: [String] = [] var values: [Int] = [] func copy() -> Storage { let s = Storage() s.keys = keys s.values = values return s } } public struct

Re: [swift-users] Problem with mutable views and COW

2016-11-18 Thread Adrian Zubarev via swift-users
I’m sorry but you seem not to understand what I’m asking for! If you don’t know what a mutable view is, please read this proposal to get the basic idea: https://github.com/natecook1000/swift-evolution/blob/nc-dictionary-collections/proposals/-dictionary-key-and-value-collections.md Your

Re: [swift-users] Problem with mutable views and COW

2016-11-18 Thread Adrian Zubarev via swift-users
Ups sorry for CCing the post to the evolution list. That happens from time to time. :/ --  Adrian Zubarev Sent with Airmail Am 18. November 2016 um 15:07:43, Adrian Zubarev (adrian.zuba...@devandartist.com) schrieb: I apologize about the weak/unowned issue I mentioned. I kinda missed that

Re: [swift-users] Problem with mutable views and COW

2016-11-18 Thread Adrian Zubarev via swift-users
This doesn’t make any sense. Somewhere from the Swift book: Weak and unowned references enable one instance in a reference cycle to refer to the other instance without keeping a strong hold on it. The instances can then refer to each other without creating a strong reference cycle. From the

Re: [swift-users] Problem with mutable views and COW

2016-11-18 Thread Zhao Xin via swift-users
>Why is the second check false, even if the property is marked as unowned for the view? Please search the mailing list, this is not the first time it comes as a new question. Shortly speaking, it is `false` only because you used `unowned`. If you you can grantee it always exists. Just use it

[swift-users] Problem with mutable views and COW

2016-11-18 Thread Adrian Zubarev via swift-users
Hi there, I just can’t get my head around mutable views and COW. Here is a small example: final class Storage { var keys: [String] = [] var values: [Int] = [] } public struct Document { var _storageReference: Storage public init() {