<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">For me and my English its become hard to follow where this is going right now.</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">Let’s stick with my `AnyReference` and `AnyValue` protocols just for the example.</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">Do I get your intention right that we discuss here about value types that are constructed from their deepest only from other value types (same for `PureReferences`)? That’s what my understanding is for `PureValue`.</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> +-----+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> | Any |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> +--+--+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> +-------------+-------------+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> | |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> +------+-------+ +-----+----+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> | AnyReference | | AnyValue |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> +--+---+-------+ +-----+----+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> | | |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular">+-------+-------+ +-----+-----+ </font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular">| PureReference | | PureValue | </font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular">+---------------+ +-----+-----+ </font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular">+---+--------------+ </font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular">| AnyObject (ObjC) | </font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular">+------------------+</font></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">Side note: If SE-0083 will be accepted it might be possible that @objc will be dropped from `AnyObject`, correct me if I'm wrong.</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">I'm fine with that if that’s the case, but I'm not if one-day Swift won't allow anymore to mix value types with reference types.</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">I also don't think that `PureReference` and `PureValue` protocols could be implicit, but their base protocols can.</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">Explicit usage of these protocols on actual types:</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">class A: PureValue {} // won't work</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">class B: PureReference {</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><span class="Apple-tab-span" style="white-space:pre">        </span>var value: OtherClass</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">} // can only contain only reference types (if that’s what we've been talking about here)</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">struct C: PureReference {} // won't work</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">struct D: PureValue {</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><span class="Apple-tab-span" style="white-space:pre">        </span>var value: Int</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">} // can only contain value types, and all value types inside follow the same rule</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">Explicit usage on protocols:</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">protocol E: SomeOtherProtocol, PureReference {} // shouldn't work, because if we want to replace the `class` keyword we should at least the rule that out constraint protocols should sit right behind `: ` or behind Any(Reference/Value) which will take the first place instead.</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">protocol F: PureReference {</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><span class="Apple-tab-span" style="white-space:pre">        </span>var value: SomeClass { get }</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">} // can only be applied to types that follow the pure reference constraint + SomeClass should follow the pure reference rule</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">protocol G: F {} // same as F</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">protocol H: SomeOtherProtocol, PureValue {} // same problem as with E</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">protocol I: PureValue {</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><span class="Apple-tab-span" style="white-space:pre">        </span>var value: Int</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><span class="Apple-tab-span" style="white-space:pre">        </span>func foo() -> Int</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">} // same rule as with class D</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">protocol J: PureValue {</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><span class="Apple-tab-span" style="white-space:pre">        </span>var value: SomeClass</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">} // should not work</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">protocol K: PureValue {</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><span class="Apple-tab-span" style="white-space:pre">        </span>func foo() -> SomeClass</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">} // I guess this should not work!?</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">protocol L: PureReference {</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><span class="Apple-tab-span" style="white-space:pre">        </span>func foo() -> Int</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">} // should this work?</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">protocol M: PureReference {</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><span class="Apple-tab-span" style="white-space:pre">        </span>func foo() -> SomeClass</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">} // like F</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">Implicit usage of the Any protocols:</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">class N {</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><span class="Apple-tab-span" style="white-space:pre">        </span>var value: SomeValue</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><span class="Apple-tab-span" style="white-space:pre">        </span>var anotherValue: SomeClass</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><span class="Apple-tab-span" style="white-space:pre">        </span>func foo() -> Int</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><span class="Apple-tab-span" style="white-space:pre">        </span>func boo() -> AClass</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">} // implicitly AnyReference; SomeClass can follow PureReference rule but still can be nested into a AnyClass or AnyValue type (same goes for SomeValue)</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">struct O {</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><span class="Apple-tab-span" style="white-space:pre">        </span>var value: SomeValue</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><span class="Apple-tab-span" style="white-space:pre">        </span>var anotherValue: SomeClass</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><span class="Apple-tab-span" style="white-space:pre">        </span>func foo() -> Int</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><span class="Apple-tab-span" style="white-space:pre">        </span>func boo() -> AClass</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">} // implicitly AnyValue; same rules as for N</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">Explicit protocol constrains:</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">protocol P: AnyValue, PureValue {} // or just PureValue</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">protocol Q: AnyReference, PureReference {} or just PureReference</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">protocol R: AnyValue {} // This protocol is problematic now, because logically we could apply it to a PureValue type but this shouldn’t work, just because we said that PureProtocols are more constrained</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">Now we have two options:</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">1. Split the Any and Pure concepts</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> +------+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> | Pure |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> +--+---+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> +-------------+-------------+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> | |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular">+------+--------+ +-----+-----+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular">| PureReference | | PureValue |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular">+---------------+ +-----+-----+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"><br></font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> +-----+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> | Any |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> +--+--+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> +-------------+------------+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> | |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular">+------+-------+ +-----+----+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular">| AnyReference | | AnyValue |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular">+--------------+ +-----+----+</font></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">This solution feels strange. `Pure` is something like `AnyPure`.</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">2. Reorder Pure and Any protocols:</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> +-----+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> | Any |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> +--+--+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> +-------------+-------------+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> | |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular">+------+--------+ +-----+-----+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular">| PureReference | | PureValue |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular">+------+--------+ +-----+-----+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> | |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular">+------+-------+ +-----+----+ </font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular">| AnyReference | | AnyValue | </font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular">+--------------+ +-----+----+</font><span style="font-family: Helvetica, Arial; font-size: 13px;"> </span></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">protocol R: AnyValue {} // is fine now because we can't apply it to a PureValue anymore.</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">With this reorder I suggest that `PureValue` and `PureReference` also becomes implicit protocols, BUT all existing types should be implicitly `AnyReference` or `AnyValue` where the strict rule from `PureProtocols` is ignored/disabled. To use the constraints of pure protocols should require its explicit usage.</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">Does this make any sense to you or am I totally wrong here?</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">What I’d prefer could look like this:</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> +-----+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> | Any |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> +--+--+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> +-------------+------------+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular"> | |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular">+------+-------+ +-----+----+</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular">| AnyReference | | AnyValue |</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="SourceCodePro-Regular">+--------------+ +-----+----+</font></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">pure protocol A: AnyReference {}</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">pure class B: A {}</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;"><br></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;">I'm not sure why this topic become so complicated where we only discussed about dropping the `class` keyword from protocols and I suggested to use implicit protocols instead, where we need at least one more for value types (I'm fine with `AnyObject` as long it won't bridge to ObjC types anymore, but I'd rename it for possible new reference type in the future of Swift).</div></div> <br> <div id="bloop_sign_1462611029833807872" class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">-- <br>Adrian Zubarev<br>Sent with Airmail</div></div> <br><p class="airmail_on">Am 7. Mai 2016 bei 09:56:24, Tyler Fleming Cloutier via swift-evolution (<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>) schrieb:</p> <blockquote type="cite" class="clean_bq"><span><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div></div><div>
<title></title>
<br class="">
<div>
<blockquote type="cite" class="">
<div class="">On May 5, 2016, at 8:02 PM, Dave Abrahams via
swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">on Thu May 05 2016, Matthew Johnson <</span><a href="http://matthew-at-anandabits.com/" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">matthew-AT-anandabits.com</a><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">> wrote:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""> On May 5, 2016, at 4:59 PM, Dave
Abrahams <<a href="mailto:dabrahams@apple.com" class="">dabrahams@apple.com</a>> wrote:<br class="">
<br class="">
on Wed May 04 2016, Matthew Johnson <<a href="http://matthew-at-anandabits.com" class="">matthew-AT-anandabits.com</a>> wrote:<br class="">
<br class="">
On May 4, 2016, at 5:50
PM, Dave Abrahams via swift-evolution<br class="">
<<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class="">
<br class="">
on Wed May 04 2016,
Matthew Johnson <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class="">
<br class="">
On May 4, 2016, at 1:29
PM, Dave Abrahams via swift-evolution<br class="">
<<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class="">
<br class="">
on Wed May 04 2016,
Adrian Zubarev <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>><br class="">
wrote:<br class="">
<br class="">
Not sure what to think
about the enum cases inside a<br class="">
protocol (if AnyEnum
would<br class="">
even exist), it could be
a nice addition to the language, but<br class="">
this is an own<br class="">
proposal I
guess.<br class="">
<br class="">
We should start by adding
AnyValue protocol to which all value<br class="">
types<br class="">
conforms.<br class="">
<br class="">
Having a way to constrain
conformance to things with value semantics<br class="">
is<br class="">
something I've long
wanted. *However*, the approach described is too<br class="">
simplistic. It's possible
to build classes whose instances have<br class="">
value<br class="">
semantics (just make them
immutable) and it's possible to build<br class="">
structs<br class="">
whose instances have
reference semantics (just put the struct's<br class="">
storage<br class="">
in a mutable class
instance that it holds as a property, and don't<br class="">
do<br class="">
copy-on-write).<span class="Apple-converted-space"> </span><br class="">
<br class="">
In order for something
like AnyValue to have meaning, we need to<br class="">
impose<br class="">
greater order. After
thinking through many approaches over the<br class="">
years, I<br class="">
have arrived at the
(admittedly rather drastic) opinion that the<br class="">
language should
effectively outlaw the creation of structs and enums<br class="">
that don't have value
semantics. (I have no problem with the idea<br class="">
that<br class="">
immutable classes that
want to act as values should be wrapped in a<br class="">
struct). The language
could then do lots of things much more<br class="">
intelligently, such as
correctly generating implementations of<br class="">
equality.<br class="">
<br class="">
That is a drastic
solution indeed! How would this impact things like<br class="">
Array<UIView>?
While Array itself has value semantics, the aggregate<br class="">
obviously does not as it
contains references which usually be mutated<br class="">
underneath
us.<span class="Apple-converted-space"> </span><br class="">
<br class="">
Value semantics and
mutation can only be measured with respect to<br class="">
equality. The definition
of == for all class types would be equivalent<br class="">
to ===. Problem
solved.<br class="">
<br class="">
Similar considerations
apply to simpler wrapper structs such as Weak.<br class="">
<br class="">
Same answer.<br class="">
<br class="">
Hmm. If those qualify as
“value semantic” then what kind of structs and<br class="">
enums<br class="">
would not? A struct
wrapping a mutable reference type certainly doesn’t<br class="">
“feel”<br class="">
value semantic to me and
certainly doesn’t have the guarantees usually<br class="">
associated with value
semantics (won’t mutate behind your back, thread<br class="">
safe,<br class="">
etc).<br class="">
<br class="">
Sure it does.<br class="">
<br class="">
public struct Wrap<T: AnyObject> :
Equatable {<br class="">
init(_ x: T) { self.x = x }<br class="">
private x: T<br class="">
}<br class="">
<br class="">
func == <T>(lhs: Wrap<T>, rhs:
Wrap<T>) -> Bool {<br class="">
return lhs.x === rhs.x<br class="">
}<br class="">
<br class="">
I defy you to find any scenario where
Wrap<T> doesn't have value<br class="">
semantics, whether T is mutable or not.<br class="">
<br class="">
Alternately, you can look at the Array
implementation. Array is a<br class="">
struct wrapping a mutable class. It has value
semantics by virtue of<br class="">
CoW.<br class="">
<br class="">
This goes back to where you draw the line as to the “boundary of
the value”.<br class="">
Wrap and Array are “value semantic” in a shallow sense and are
capable of deep<br class="">
value semantics when T is deeply value semantic.<span class="Apple-converted-space"> </span><br class=""></blockquote>
<br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">No, I'm sorry; this “deep-vs-shallow” thing is a fallacy
that comes from</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">not understanding the boundaries of your value. Or,
put more</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">solicitously: sure, you can look at the world that way,
but it just</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">makes everything prohibitively complicated, so why would
you want to?</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">In my world, there's no such thing as a “deep copy” or a
“shallow copy;”</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">there's just “copy,” which logically creates an
independent version of</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">everything up to the boundaries of the value.
Likewise, there's no</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">“deep value semantics” or “shallow value semantics.”
Equality defines</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">value semantics, and the boundaries of an Array value
always includes</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">the values of its elements. The *only* problem here
is that we have no</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">way to do equality comparison on some arrays because some
types aren't</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Equatable. IMO the costs of not having everything be
equatable, in</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">complexity-of-programming-model terms, are too
high.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div>
</blockquote>
<div><br class=""></div>
<div>My point with this is, in case I was a bit rambling, if you’re
going to draw boundaries around a value, for the purpose of copying
or immutability, then equality should always match with those
boundaries. As you say, “Equality defines value semantics, and the
boundaries of an Array value always includes the values of its
elements.”</div>
<div><br class=""></div>
<div>Under this reasoning, custom equality violates these
boundaries. And without custom equality, equality checks on
reference types are essentially useless. But maybe value types in
Swift are powerful enough where this doesn’t matter.</div>
<div><br class=""></div>
<br class="">
<blockquote type="cite" class="">
<div class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Both have their place, but the maximum benefit of value
semantics<br class="">
(purity)<span class="Apple-converted-space"> </span><br class=""></blockquote>
<br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I don't know what definition of purity you're using.
The only one I</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">know of applies to functions and implies no side effects.
In that</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">world, there is no mutation and value semantics is
equivalent to</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">reference semantics.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">is derived from deep value semantics. This is when there
is no<br class="">
possibility of shared mutable state. This is an extremely
important<br class="">
property.<br class=""></blockquote>
<br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">It's the wrong property, IMO.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="">
let t = MyClass()<br class="">
foo.acceptWrapped(Wrap(t))<br class="">
t.mutate()<br class="">
<br class="">
In this example, foo had better not depend on the wrapped instance
not getting<br class="">
mutated.<br class=""></blockquote>
<br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">foo has no way to get at the wrapped instance, so it can't
depend on</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">anything about it.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""> My expectation
is a generic aggregate such as Array would have to<br class="">
conditionally conform to
AnyValue only when Element also conforms to<br class="">
AnyValue.<br class="">
<br class="">
I’m also wondering how
such a rule would be implemented while still<br class="">
allowing for CoW structs
that *do* implement value semantics, but do<br class="">
so while using references
internally.<br class="">
<br class="">
I am not talking about
any kind of statically-enforceable rule, although<br class="">
we could probably make
warnings sophisticated enough to help with this.<br class="">
<br class="">
You said the you have
arrived at the opinion that the language should<br class="">
“effectively outlaw”
structs and enums that do not have value semantics.<br class="">
That<br class="">
sounded like static
enforcement to me.<span class="Apple-converted-space"> </span><br class="">
<br class="">
The language outlaws certain kinds of inout
aliasing without<br class="">
providing static enforcement. This is like
that.<br class="">
<br class="">
I did not know this. Now you have me curious. Can you give an
example of where<br class="">
we are able to violate law? I ask mostly because it sounds like
there is a<br class="">
possibility of stumbling into dangerous territory, possibly without
being aware<br class="">
that you have done so.<br class=""></blockquote>
<br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">See “In-out Parameters” in</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Declarations.html#//apple_ref/doc/uid/TP40014097-CH34-ID362" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Declarations.html#//apple_ref/doc/uid/TP40014097-CH34-ID362</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""> Maybe you meant
we should allow the compiler to assume value semantics<br class="">
for structs and enums
despite the fact that it doesn’t statically<br class="">
enforce this?<br class="">
<br class="">
That would be one *consequence* of effectively
outlawing it. The library<br class="">
could make similar assumptions.<br class="">
<br class="">
If the compiler can be
sophisticated enough to verify value semantics<br class="">
statically maybe it would
be better to have that mechanism be<br class="">
triggered by conformance
to AnyValue rather than for all structs and<br class="">
enums. Types that conform
to AnyValue would receive the benefits of<br class="">
the compiler knowing they
have value semantics, while other uses of<br class="">
structs and enums would
remain valid. Best practice would be to<br class="">
conform structs and enums
to AnyValue whenever possible.<br class="">
<br class="">
Another possible
advantage of this approach would be allowing<br class="">
immutable reference types
to conform to AnyValue and receive the<br class="">
associated benefits such
as the generated implementation of equality,<br class="">
etc.<br class="">
<br class="">
-Matthew<br class="">
<br class="">
--<span class="Apple-converted-space"> </span><br class="">
Dave<br class="">
<br class="">
_______________________________________________<br class="">
swift-evolution mailing
list<br class="">
<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class="">
_______________________________________________<br class="">
swift-evolution mailing
list<br class="">
<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class="">
--<span class="Apple-converted-space"> </span><br class="">
Dave<br class="">
<br class="">
_______________________________________________<br class="">
swift-evolution mailing
list<br class="">
<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class="">
--<span class="Apple-converted-space"> </span><br class="">
Dave<br class="">
<br class=""></blockquote>
<br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">--<span class="Apple-converted-space"> </span></span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Dave</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<a href="mailto:swift-evolution@swift.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div>
</blockquote>
</div>
<br class="">
_______________________________________________<br>swift-evolution mailing list<br>swift-evolution@swift.org<br>https://lists.swift.org/mailman/listinfo/swift-evolution<br></div></div></span></blockquote></body></html>