<div dir="ltr"><div>2016-07-15 0:02 GMT+03:00 Adrian Zubarev via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><p>I still can’t get my head around this.</p><p>Originally I wanted to seal <code>T.Type</code> completely but I realized that there are to many downsides, therefore I think it’s better to revise the way how we construct a metatype in Swift + how to solve the ambiguity in array/dictionary shorthand syntax + open the door for reflections + combining SE–0101 into <code>Type&lt;T&gt;</code>.</p><p>I don’t think we have to make the whole model of <code>Type&lt;T&gt;</code> that complicated that it contains different identifier for each type. This is already solved with metatypes.</p></div></blockquote></div><div>We can have a field of type <font face="monospace, monospace">T.Type</font>, that is what I meant, no need in <font face="monospace, monospace">_uniqueIdentifier</font>.<br></div><div><div class="gmail_extra"><div class="gmail_quote"><div>My point is that if we want to remove <font face="monospace, monospace">T.Type</font><font face="arial, helvetica, sans-serif"> from the language</font>, then we can&#39;t just refer to it in docs.</div><div>We can use whatever we want for implementation, though.</div></div></div></div><div class="gmail_extra"><br></div><div class="gmail_extra"><blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex" class="gmail_quote">The thing I believe you misinterpret with <code>Type&lt;T&gt;</code> being the same as <code>T.Type</code> is that if <code>Type&lt;T&gt;</code> would act like <code>T.Type</code>:<br><code>T.self.init == T.init<br></code><code>T.self.staticMember == T.staticMember<br></code>We won’t be able to extend <code>Type&lt;T&gt;</code> at all because otherwise all static members of <code>Type&lt;T&gt;</code> would be reserved and cannot be implemented in <code>T</code>, which is clearly not how it should work.<br><code>Type&lt;T&gt;.init != T.init<br></code><code>Type&lt;T&gt;.staticMember != T.staticMember  <br></code>Thats why I’m talking about the <code>metatype</code> property all the time.</blockquote><p style=""><font face="arial, helvetica, sans-serif">Ok, I forgot about it. </font><font face="monospace, monospace">Type&lt;T&gt;</font><span style="font-family:arial,helvetica,sans-serif"> should have all features of </span><font face="monospace, monospace">T.Type</font><span style="font-family:arial,helvetica,sans-serif">, <i>except that</i> </span><font face="monospace, monospace">Type&lt;T&gt;</font><span style="font-family:arial,helvetica,sans-serif"> will not contain static methods of T.</span></p><div>I still can&#39;t see any concrete examples where this behaviour is necessary. Metatypes <font face="monospace, monospace">T.Type</font> can become an implementation detail of <font face="monospace, monospace">Type&lt;T&gt;</font>.</div><div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><font face="monospace, monospace">    // do not construct full `Type&lt;T&gt;` - use lightweight static calculation instead<br>    public var size: Int { return Type&lt;T&gt;.size }<br>    public var stride: Int { return Type&lt;T&gt;.stride }<br>    public var alignment: Int { return Type&lt;T&gt;.alignment }<br>     <br>    public static var size: Int { return _sizeof(Type&lt;T&gt;.metatype) }<br>    public static var stride: Int { return _strideof(Type&lt;T&gt;.metatype) }<br>    public static var alignment: Int { return _alignof(Type&lt;T&gt;.metatype) }</font></blockquote><div> </div></div><div>I agree with most of the code (without <font face="monospace, monospace">_uniqueIdentifier</font>) but not with this. Consider this example:</div><div><br></div><div><font face="monospace, monospace">let x = Type&lt;Int&gt;()</font></div><div><font face="monospace, monospace">let y = Type&lt;CustomStringConvertible&gt;(casting: x)!</font></div><span style="font-family:monospace,monospace">x.size  //=&gt; 8</span><div><font face="monospace, monospace">y.size  //=&gt; 8 or 40?</font></div><div><br></div><div>I think that <font face="monospace, monospace">y.size</font> should be 8, because we are dynamically checking size of particular type <font face="monospace, monospace">y</font>, specific subtype of <font face="monospace, monospace">CustomStringConvertible</font>. We should look into corresponding witness table or whatever, and get the size at runtime.</div></div></div>