Re: [swift-users] Chaining struct-mutating funcs

2016-08-10 Thread Dave Abrahams via swift-users
on Tue Aug 09 2016, Fritz Anderson wrote: > I’m sending directly to those who took time over my question, because, per > Michael’s request, I have a > minimal case to attach. Phrases in boldface are for skimmability, not > shouting. > > Strip out my use case (I’m encouraged that Dave recapitu

Re: [swift-users] Chaining struct-mutating funcs

2016-08-08 Thread Dave Abrahams via swift-users
on Fri Aug 05 2016, Joe Groff wrote: > Since your backing buffer is copy-on-write, you can do the in-place > mutation optimization in your immutable implementations, something > like this: > > class C { > var value: Int > init(value: Int) { self.value = value } > } > > struct S { var c: C }

[swift-users] Chaining struct-mutating funcs

2016-08-05 Thread Fritz Anderson via swift-users
Swift 3 as of Xcode 8.0b4 TL;DR: I have a struct value type backed by a copy-on-write mutable buffer. You use it to perform arithmetic on the buffers. The most expressive way to do this efficiently is to chain the arithmetic operators so each mutates the same buffer. Swift does not like to chai

Re: [swift-users] Chaining struct-mutating funcs

2016-08-05 Thread Joe Groff via swift-users
Since your backing buffer is copy-on-write, you can do the in-place mutation optimization in your immutable implementations, something like this: class C { var value: Int init(value: Int) { self.value = value } } struct S { var c: C } func addInts(x: S, y: S) -> S { var tmp = x // Don't

[swift-users] Chaining struct-mutating funcs

2016-08-05 Thread Fritz Anderson via swift-users
Swift 3 as of Xcode 8.0b4 TL;DR: I have a struct value type backed by a copy-on-write mutable buffer. You use it to perform arithmetic on the buffers. The most expressive way to do this efficiently is to chain the arithmetic operators so each mutates the same buffer. Swift does not like to chai