SE-0258: Property Delegates

Just to be clear, does something like the private(storage) future direction meet your criteria here, or do you feel that there is a deeper problem with the design that needs to be addressed?

I think we can provide a more natural CopyOnWrite wrapper using generalized accessors, since modify is able to do the uniqueness check and efficiently yield the unique value. I've been meaning to try it with the toolchain, because _modify is in the compiler already. Should the property delegates proposal examples depend on this experimental feature? I guess it could.

Huh, I thought I had addressed this. The intent is that Box is for creating storage, and Ref is about referring to something that's either directly in a Box, formed through some other get / set pair (say, a computed value), or derived via key path from another Ref thing.

I liked your idea of doing Definite Initialization for the $ property based on init(initialDelegateValue:). Haven't had time to implement it yet, but it seems like a reasonable addition here.

Alternatively, one could make the $foo private in such cases. That gives you direct initialization and hides it from the outside world.

I'm fairly strongly against this direction, because delegate types are normal types. The "weirdness" should be in accessing the backing storage of the property that has a delegate; once you have that value, it's just a normal value of the delegate type.

FWIW, autocomplete can support this design, too, by inserting the '$' earlier. There's some precedent here with insertion of ? in someOptional.<completion shows members of the wrapped type>.

It is smart enough to do that through init(initialValue:). As mentioned above, it could do the same for an init(initialDelegateValue:).

Doug