[swift-evolution] Improved value and move semantics

Chris Lattner clattner at apple.com
Wed Aug 3 18:58:21 CDT 2016

On Aug 3, 2016, at 6:41 AM, Matthew Johnson via swift-evolution <swift-evolution at swift.org> wrote:
>>> Then you can just slap `indirect` on a struct whose copying is too
>>> complicated and let Swift transparently COW it for you. (And it would
>>> also permit recursive structs and other such niceties.)
>> My vision for this feature is:
>> a. We indirect automatically based on some heuristic, as an
>>  optimization.

I weakly disagree with this, because it is important that we provide a predictable model.  I’d rather the user get what they write, and tell people to write ‘indirect’ as a performance tuning option.  “Too magic” is bad.

>> b. We allow you to indirect manually.
>> c. We provide an attribute that suppresses automatic indirection to
>>  whatever depth possible given resilience boundaries.
> This all sounds great.  Does any of this fit into Swift 4 (either phase 1 or phase 2)?  It seems like at least the automatic part would have ABI impact.

This is very low priority, because it is generally additive. After the major topics for ABI stability are figured out, we can have the philosophic discussion about the automatic part.


More information about the swift-evolution mailing list