[swift-users] inout params seem to have undefined behavior
davesweeris at mac.com
Sun Jun 12 02:33:42 CDT 2016
Oh, ok, I stand corrected. Thanks for the link :-)
Sent from my iPhone
On Jun 11, 2016, at 18:05, Brent Royal-Gordon <brent at architechies.com> wrote:
>> My recollection is that in Swift the subscript operator (`arr` in this case) can refer to the setter xor the getter, but not both within the same statement.
> Quite to the contrary. Rather than using the setter directly, Swift often uses `materializeForSet`, a combined get-and-set operation which is much more efficient, particularly when assigning directly into arrays. To keep from having to use very slow access all the time, it imposes a rule (which is not and cannot be enforced by the compiler) that you can't hold two mutable references to overlapping storage simultaneously, or they may do strange things like lose some of the writes you make.
> Here's an old design document discussing some things in this area: <https://github.com/apple/swift/blob/73841a643c087e854a2f62c7e073317bd43af310/docs/proposals/Accessors.rst> I'm not sure how authoritative it is, but it might give you an idea of what's going on.
> Brent Royal-Gordon
More information about the swift-users