on Thu Apr 28 2016, Pyry Jahkola <[email protected]> wrote: > Good that you brought the topic of "fluent" interfaces up. I don't see any > problem with explicit value type mutation and method chaining because fluent > interfaces are constrained to reference types by the language. Details below: > > On 28 Apr 2016, at 03:44, Tyler Cloutier > <[email protected]> wrote: > > How would this chain if I wanted to do something like: > > let median = foo.calculateBigHugeArray().sort().medianValue() > > and I want the sort to be done in place. > > I think I can guess what you wanted the above to mean but, mind you, the > in-place sort returns `()` so you wouldn't chain its result like that. On the > other hand, the above code already works using the non-mutating `.sort()` (to > be > known as `.sorted()` in Swift 3), and—correct me if I'm wrong—the compiler > probably optimises the copy away using copy-on-write anyway.
No, the compiler can't automatically turn non-mutating operations into in-place operations. -- Dave _______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
