[Swift-devel] swift write once array/struct

Mihael Hategan hategan at mcs.anl.gov
Sat Mar 21 12:28:12 CDT 2015


On Sat, 2015-03-21 at 10:38 -0500, Ketan Maheshwari wrote:
> Hi Tim,
> 
> Thanks for the clarification and code snippet. To clarify, in my
> understanding, the implementation is 'extrinsic'.
> 
> To be intrinsic, I imagined the array is implemented as an object which has
> a function that monitors and controls its write-once property and gets
> invoked every time anything is written to any element of the array.

The array is implemented as you describe above. I'm not really sure what
extrinsic would be.

Calls to an object's methods aren't automatically synchronized or
atomic, so I don't think that assumption in your earlier email is
correct.

Even if they were, having this particular method atomic does not
guarantee that there would be no deadlocks. A user can write a[0] =
f(a[1]); a[1] = f(a[0]);

Mihael




More information about the Swift-devel mailing list