[swift-evolution] Improved value and move semantics

Chris Lattner clattner at apple.com
Sun Aug 7 23:42:38 CDT 2016

On Aug 4, 2016, at 8:26 AM, Matthew Johnson <matthew at anandabits.com> wrote:
>>> Depending on the structure of their data.  In any case, to reiterate, this really isn’t the time to have this debate, since it is clearly outside of stage 1.
>> In my mind, indirect *is* cow. An indirect struct without value semantics is a class, so there would be no reason to implement 'indirect' for structs without providing copy-on-write behavior.
> This is my view as well.  Chris, what is the distinction in your mind?

Yes, this is correct, my mistake.  Artifact of it not being in scope for Swift 4s1 so I can’t keep it in-core right now. :-)

>> I believe that the situation with structs and enums is also different. Indirecting enums has a bigger impact on interface because they enable recursive data structures, and while there are places where indirecting a struct may make new recursion possible, that's much rarer of a 

I really don’t want to draw out this discussion, but I’ll observe that indirect on enums “cheat” in their implementation, because there is no way to get an internal reference with writeback semantics.  Because of that, all mutations are effectively overwrites of the entire enum value.

If you could pattern match an in-place mutable reference to the payload of an enum case then our implementation model would have to change.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160807/8c6a924b/attachment.html>

More information about the swift-evolution mailing list