<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Howard,<div class=""><br class=""></div><div class="">I appreciate the amount of thought and detail you've put into both the proposal and these replies.</div><div class=""><br class=""></div><div class="">However, the fundamental objection I have is that this proposal makes the type system unsound. More specifically, all your examples contain calls to precondition() and force casts, because it would become possible to write incorrectly typed code that nevertheless passes the type checker. The idea that user-level code would have to pervasively perform type checking at runtime when using generic code or risk causing a program-terminating exception goes against the design philosophy the core team has articulated for the language. Optionals and non-nullable types are (at least at first) a pain to use for a programmer used to working in a language where nil/null is a bottom type, but their presence isolates the possibility of NPEs to code that is clearly delineated by '!'. In my opinion (and others may not share this opinion), the programmer convenience gained over a system where variance is annotated explicitly is not worth introducing ways to express a new category of bugs.</div><div class=""><br class=""></div><div class="">Going by your implementation below:</div><div class=""><br class=""></div><div class="">let intBox = Box(1) // intBox is of type Box&lt;Int&gt;</div><div class="">var someBox : Box&lt;Any&gt; = intBox // since covariance, this is an upcast; succeeds unconditionally; could do this with a class hierarchy as well</div><div class="">// someBox is a copy of intBox, which means although the type system thinks it's a Box&lt;Any&gt;, its BoxT is still Int's type</div><div class="">// ...</div><div class="">// much later</div><div class="">let value : Any = "hello"</div><div class="">someBox.value = value // Box&lt;Any&gt; should accept an Any, but this will cause the precondition to fail and the program to crash</div><div class="">// *any* time you mutate a Box whose value isn't a bottom type your code needs to do a typecheck, or your program dies</div><div class=""><br class=""></div><div class="">Note that arrays in Swift are actually a covariant generic type already, but because of the way their value semantics work they are immune to this problem.</div><div class=""><br class=""></div><div class="">You can try to paper over this problem by introducing (e.g.) compiler magic which adjusts the metatype properties in conjunction with upcasts and downcasts, but what happens when the covariant generic type is a class and you can't rely on copy-on-assignment behavior? etc.</div><div class=""><br class=""></div><div class="">There are other languages that have chosen to make generic types pervasively covariant (e.g.&nbsp;<a href="https://www.dartlang.org/articles/why-dart-types/" class="">https://www.dartlang.org/articles/why-dart-types/</a>), but each language has its own design philosophy and I don't think this is the right direction for Swift. I think once the case has been made as to why this Swift-specific convenience-over-safety tradeoff should favor convenience, it'll be easier to discuss additional pros and cons of your specific implementation.</div><div class=""><br class=""></div><div class="">Best,</div><div class="">Austin</div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Jan 12, 2016, at 11:22 PM, Howard Lovatt &lt;<a href="mailto:howard.lovatt@gmail.com" class="">howard.lovatt@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">@Austin,<div class=""><br class=""></div><div class="">I don't see a problem with the collections in general, that's why I chose `Box` as an example - the smallest possible collection!&nbsp;<div class=""><br class=""></div><div class="">Is this what you had in mind?<div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: Use a Box as an example of a minimal collection, a colection of exactly one value!</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: - note:</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: In earlier examples I used the generic type name as the feild name directly, in practice you need a unique name.</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: I would propose TypeName.GenericName for the unique name?</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: In examples below I have used TypeNameGenericName as the nearest approximation possible at present.</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: I chose upper case, but maybe lower case better?</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: Maybe the syntax without a . is good enough?</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: &nbsp; &nbsp; protocol Boxable&lt;T&gt; { var value: T { get set } }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color:rgb(187,44,162)" class="">protocol</span> Boxable {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">var</span> BoxableT: <span style="color:rgb(112,61,170)" class="">Any</span>.Type { <span style="color:rgb(187,44,162)" class="">get</span> }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">var</span> value: <span style="color:rgb(112,61,170)" class="">Any</span> { <span style="color:rgb(187,44,162)" class="">get</span> <span style="color:rgb(187,44,162)" class="">set</span> }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: &nbsp; &nbsp; protocol Generatable&lt;T&gt; { var generator: Generator&lt;T&gt; { get } }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color:rgb(187,44,162)" class="">protocol</span> Generatable {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">var</span> GeneratableT: <span style="color:rgb(112,61,170)" class="">Any</span>.Type { <span style="color:rgb(187,44,162)" class="">get</span> }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">var</span> generator: <span style="color:rgb(79,129,135)" class="">Generator</span> { <span style="color:rgb(187,44,162)" class="">get</span> }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: &nbsp; &nbsp; struct Box&lt;T&gt;: Boxable&lt;T&gt;, Generatable&lt;T&gt; {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: &nbsp; &nbsp; &nbsp; &nbsp; var value: T</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: &nbsp; &nbsp; &nbsp; &nbsp; var generator: Generator&lt;T&gt; { return BoxGenerator(box: self) }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: &nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135);" class=""><span style="color:rgb(187,44,162)" class="">struct</span><span style="" class=""> Box: </span>Boxable<span style="" class="">, </span>Generatable<span style="" class=""> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="color:rgb(187,44,162)" class="">let</span><span style="" class=""> BoxT: </span><span style="color:rgb(112,61,170)" class="">Any</span><span style="" class="">.Type </span>// Box only has one 'real' generic type BoxT</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="color:rgb(187,44,162)" class="">var</span><span style="" class=""> BoxableT: </span><span style="color:rgb(112,61,170)" class="">Any</span><span style="" class="">.Type { </span>// BoxableT declared as same as BoxT (Boxable&lt;T&gt;)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">return</span> <span style="color:rgb(79,129,135)" class="">BoxT</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="color:rgb(187,44,162)" class="">var</span><span style="" class=""> GeneratableT: </span><span style="color:rgb(112,61,170)" class="">Any</span><span style="" class="">.Type { </span>// GeneratableT declared as same as BoxT (Generatable&lt;T&gt;)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">return</span> <span style="color:rgb(79,129,135)" class="">BoxT</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">private</span> <span style="color:rgb(187,44,162)" class="">var</span> _value: <span style="color:rgb(112,61,170)" class="">Any</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">var</span> value: <span style="color:rgb(112,61,170)" class="">Any</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">get</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">return</span> <span style="color:rgb(79,129,135)" class="">_value</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">set</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:rgb(61,29,129)" class="">precondition</span><span style="" class="">(</span><span style="color:rgb(79,129,135)" class="">BoxT</span><span style="" class=""> == </span><span style="color:rgb(0,132,0)" class="">/* &gt;= */</span><span style="" class=""> newValue.</span><span style="color:rgb(187,44,162)" class="">dynamicType</span><span style="" class="">, </span>"Type of newValue, <span style="" class="">\</span>(<span style="" class="">newValue.</span><span style="color:rgb(187,44,162)" class="">dynamicType</span>), is not a sub-type of generic type BoxT, <span style="" class="">\</span>(<span style="color:rgb(79,129,135)" class="">BoxT</span>)"<span style="" class="">)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(79,129,135)" class="">_value</span> = newValue</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">var</span> generator: <span style="color:rgb(79,129,135)" class="">Generator</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">return</span> <span style="color:rgb(79,129,135)" class="">BoxGenerator</span>(<span style="color:rgb(79,129,135)" class="">BoxT</span>, box: <span style="color:rgb(187,44,162)" class="">self</span>)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="" class="">&nbsp; &nbsp; </span>// Generated from `init(_ initialValue: T)` and noting that `T`'s upper bound is `AnyObject`.</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">init</span>(<span style="color:rgb(187,44,162)" class="">_</span> lowestCommonDeclaredT: <span style="color:rgb(112,61,170)" class="">Any</span>.Type, value: <span style="color:rgb(112,61,170)" class="">Any</span>) {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(79,129,135)" class="">BoxT</span> = lowestCommonDeclaredT</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(79,129,135)" class="">_value</span> = value</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: &nbsp; &nbsp; protocol Generator&lt;T&gt; { var next: T? { get } }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color:rgb(187,44,162)" class="">protocol</span> Generator {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">var</span> GeneratorT: <span style="color:rgb(112,61,170)" class="">Any</span>.Type { <span style="color:rgb(187,44,162)" class="">get</span> }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">var</span> next: <span style="color:rgb(112,61,170)" class="">Any</span>? { <span style="color:rgb(187,44,162)" class="">get</span> }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: &nbsp; &nbsp; class BoxGenerator&lt;T&gt;: Generator&lt;T&gt; {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: &nbsp; &nbsp; &nbsp; &nbsp; private var isFinished = false</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: &nbsp; &nbsp; &nbsp; &nbsp; private let box: Box&lt;t&gt;</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: &nbsp; &nbsp; &nbsp; &nbsp; var next: T? {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if isFinished { return nil }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; isFinished = true</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return box.value</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: &nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: &nbsp; &nbsp; &nbsp; &nbsp; init(box: Box&lt;T&gt;) {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.box = box</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: &nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: &nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color:rgb(187,44,162)" class="">class</span> BoxGenerator: <span style="color:rgb(79,129,135)" class="">Generator</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">let</span> BoxGeneratorT: <span style="color:rgb(112,61,170)" class="">Any</span>.Type</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">var</span> GeneratorT: <span style="color:rgb(112,61,170)" class="">Any</span>.Type {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:rgb(187,44,162)" class="">return</span><span style="" class=""> </span>BoxGeneratorT</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">private</span> <span style="color:rgb(187,44,162)" class="">var</span> isFinished = <span style="color:rgb(187,44,162)" class="">false</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">private</span> <span style="color:rgb(187,44,162)" class="">let</span> box: <span style="color:rgb(79,129,135)" class="">Box</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">var</span> next: <span style="color:rgb(112,61,170)" class="">Any</span>? {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">if</span> <span style="color:rgb(79,129,135)" class="">isFinished</span> { <span style="color:rgb(187,44,162)" class="">return</span> <span style="color:rgb(187,44,162)" class="">nil</span> }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(79,129,135)" class="">isFinished</span> = <span style="color:rgb(187,44,162)" class="">true</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">return</span> <span style="color:rgb(79,129,135)" class="">box</span>.<span style="color:rgb(79,129,135)" class="">value</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">init</span>(<span style="color:rgb(187,44,162)" class="">_</span> lowestCommonDeclaredT: <span style="color:rgb(112,61,170)" class="">Any</span>.Type, box: <span style="color:rgb(79,129,135)" class="">Box</span>) {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">self</span>.<span style="color:rgb(79,129,135)" class="">BoxGeneratorT</span> = lowestCommonDeclaredT</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">self</span>.<span style="color:rgb(79,129,135)" class="">box</span> = box</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">//: &nbsp; &nbsp; let ints = Box(value: 1)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="color:rgb(187,44,162)" class="">let</span><span style="" class=""> ints = </span><span style="color:rgb(79,129,135)" class="">Box</span><span style="" class="">(</span><span style="color:rgb(112,61,170)" class="">Int</span><span style="" class="">.</span><span style="color:rgb(187,44,162)" class="">self</span><span style="" class="">, value: </span><span style="color:rgb(39,42,216)" class="">1</span><span style="" class="">) </span>// Box&lt;Int&gt;, compiler determins declared type</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(61, 29, 129);" class="">sizeofValue<span style="" class="">(</span><span style="color:rgb(79,129,135)" class="">ints</span><span style="" class="">) </span><span style="color:rgb(0,132,0)" class="">// 40</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="color:rgb(187,44,162)" class="">let</span><span style="" class=""> intsGen = </span><span style="color:rgb(79,129,135)" class="">ints</span><span style="" class="">.</span><span style="color:rgb(79,129,135)" class="">generator</span><span style="" class=""> </span>// BoxGenerator&lt;Int&gt;</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(61, 29, 129);" class="">sizeofValue<span style="" class="">(</span><span style="color:rgb(79,129,135)" class="">intsGen</span><span style="" class="">) </span><span style="color:rgb(0,132,0)" class="">// 40</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="color:rgb(79,129,135)" class="">intsGen</span><span style="" class="">.</span><span style="color:rgb(79,129,135)" class="">next</span><span style="" class=""> </span><span style="color:rgb(187,44,162)" class="">as</span><span style="" class="">! </span><span style="color:rgb(112,61,170)" class="">Int</span><span style="" class="">? </span>// 1, compiler adds cast</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="color:rgb(79,129,135)" class="">intsGen</span><span style="" class="">.</span><span style="color:rgb(79,129,135)" class="">next</span><span style="" class=""> </span><span style="color:rgb(187,44,162)" class="">as</span><span style="" class="">! </span><span style="color:rgb(112,61,170)" class="">Int</span><span style="" class="">? </span>// nil, compiler adds cast</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Do you have something else in mind? Happy to take a look at *short* examples?</div><div class=""><br class=""></div><div class="">&nbsp;-- Howard.</div></div></div></div></div><div class="gmail_extra"><div class="gmail_quote">&nbsp;...</div></div></div></blockquote></div><br class=""></body></html>