<html><head><style>
body {
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        padding:1em;
        margin:auto;
        background:#fefefe;
}
h1, h2, h3, h4, h5, h6 {
        font-weight: bold;
}
h1 {
        color: #000000;
        font-size: 28pt;
}
h2 {
        border-bottom: 1px solid #CCCCCC;
        color: #000000;
        font-size: 24px;
}
h3 {
        font-size: 18px;
}
h4 {
        font-size: 16px;
}
h5 {
        font-size: 14px;
}
h6 {
        color: #777777;
        background-color: inherit;
        font-size: 14px;
}
hr {
        height: 0.2em;
        border: 0;
        color: #CCCCCC;
        background-color: #CCCCCC;
display: inherit;
}
p, blockquote, ul, ol, dl, li, table, pre {
        margin: 15px 0;
}
a, a:visited {
        color: #4183C4;
        background-color: inherit;
        text-decoration: none;
}
#message {
        border-radius: 6px;
        border: 1px solid #ccc;
        display:block;
        width:100%;
        height:60px;
        margin:6px 0px;
}
button, #ws {
        font-size: 12 pt;
        padding: 4px 6px;
        border-radius: 5px;
        border: 1px solid #bbb;
        background-color: #eee;
}
code, pre, #ws, #message {
        font-family: Monaco;
        font-size: 10pt;
        border-radius: 3px;
        background-color: #F8F8F8;
        color: inherit;
}
code {
        border: 1px solid #EAEAEA;
        margin: 0 2px;
        padding: 0 5px;
}
pre {
        border: 1px solid #CCCCCC;
        overflow: auto;
        padding: 4px 8px;
}
pre > code {
        border: 0;
        margin: 0;
        padding: 0;
}
#ws { background-color: #f8f8f8; }
.bloop_markdown table {
border-collapse: collapse;
font-family: Helvetica, arial, freesans, clean, sans-serif;
color: rgb(51, 51, 51);
font-size: 15px; line-height: 25px;
padding: 0; }
.bloop_markdown table tr {
border-top: 1px solid #cccccc;
background-color: white;
margin: 0;
padding: 0; }
.bloop_markdown table tr:nth-child(2n) {
background-color: #f8f8f8; }
.bloop_markdown table tr th {
font-weight: bold;
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
.bloop_markdown table tr td {
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
.bloop_markdown table tr th :first-child, table tr td :first-child {
margin-top: 0; }
.bloop_markdown table tr th :last-child, table tr td :last-child {
margin-bottom: 0; }
.bloop_markdown blockquote{
border-left: 4px solid #dddddd;
padding: 0 15px;
color: #777777; }
blockquote > :first-child {
margin-top: 0; }
blockquote > :last-child {
margin-bottom: 0; }
code, pre, #ws, #message {
word-break: normal;
word-wrap: normal;
}
hr {
display: inherit;
}
.bloop_markdown :first-child {
-webkit-margin-before: 0;
}
code, pre, #ws, #message {
font-family: Menlo, Consolas, Liberation Mono, Courier, monospace;
}
.send { color:#77bb77; }
.server { color:#7799bb; }
.error { color:#AA0000; }</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="bloop_markdown"><p>Hmmmm, currently I’m inserting some changes and tweaks into your last gist update.</p>
<blockquote>
<p>Metatypes are still in the language; it turned out that they <em>must</em> remain in the language</p>
</blockquote>
<p><code>Type<T></code> wraps around metatypes and will provide better maintenance if ever needed, because metatype instantiation will be sealed to <code>Type<T>.metatype</code> or <code>typeInstance.metatype</code>. </p>
<blockquote>
<p>The new primary <code>Type<T></code> struct duplicates semantics and interface of metatypes.</p>
</blockquote>
<p>True, but properties of a <code>Type<T></code> instance work with a ‘dynamic’ metatype, which can be up- and downcased. However static properties are used for quick access and do only with the fixed metatype for <code>T</code>.</p>
<blockquote>
<p>But it cannot get extensive native support, so it uses <code>init?(casting:)</code> instead of <code>as</code> cast, <code>is(_:)</code> method instead of <code>is</code>, etc.</p>
</blockquote>
<p>I believe this is not a huge problem. I’m sure dynamic casts can be teched to work with with <code>Type<T></code> instances. This can be purely additional and added after Swift 3.</p>
<pre><code class="swift">class A {}
class B: A {}
// In Swift 3
let typeB: Type<B> = B.self
let typeA: Type<A>? = Type<A>(casting: typeB)
let anotherTypeA: Type<A> = Type<A>(casting: typeB)!
// Post Swift 3 - Easy migration and removing `init?(casting:)`
let typeA: Type<A>? = typeB as? Type<A>
let anotherTypeA: Type<A> = typeB as! Type<A>
</code></pre>
<p>Same for for <code>is</code>:</p>
<pre><code class="swift">let typeB: Type<B> = B.self
typeB.`is`(A.self) // true
// Post Swift 3 - Easy migration and removing `func `is`(_:) -> Bool`
// Here the `is` cast extract `A` from `Type<A>` and checks the
// metatype inside of `typeB` if it's compatible with `A`
typeB is Type<A> // true
</code></pre>
<p>The <code>as</code> dynamic cast needs additional teaching post Swift 3 without any regrets.
<code>Type<T></code> would be a special case for dynamic casts.</p>
<blockquote>
<p><code>Type<T></code> does not add new possibilities right now, although the proposal promises to add reflection to <code>Type<T></code> in the future.</p>
</blockquote>
<p>This is my personal opinion, but we’d move SE–0101 into a better place tied side by side to the (dynamic) metatype. <code>MemoryLayout</code> doesn’t provide an instance of itself, it’s purely static.</p>
<p>An instance of <code>Type<T></code> can be casted and we still can get nicely all the needed information and do not need to extract the dynamic metatype.</p>
<pre><code class="swift">let typeB: Type<B> = B.self
let typeA: Type<A>? = Type<A>(casting: typeB)
let anotherTypeA: Type<A> = Type<A>(casting: typeB)!
typeB.size
typeA?.size
anotherTypeA.size
</code></pre>
<blockquote>
<p><code>Mirror</code> already does reflection. It wraps <code>Any.Type</code> statically, which is a simpler and more suitable model for reflection.</p>
</blockquote>
<p>I can’t argue on that one. The only thing that I know and have a strong feeling about is that <code>Any.Type</code> is broken. There should be <code>AnyMetatype</code> and current <code>Any.Type</code> should be the metatype for <code>Any</code> returned from the current <code>Any.self</code>. The bug is mentioned in our proposal.</p>
<p>We should move reflection to <strong>possible</strong> future direction.</p>
<blockquote>
<p>Rename metatypes <code>T.Type</code> to <code>Type<T></code></p>
</blockquote>
<p>I don’t like <code>.Type</code> the way it is right now. <code>T.Metatype</code> makes more sense, which would implies (MHO) it should be called <code>Metatype<T></code>. This is coved in our proposal.</p>
<blockquote>
<p>Rename <code>T.self</code> to <code>T</code></p>
</blockquote>
<p>It’s not about renaming here. SE–0090 aims to drop <code>.self</code> completely. Okay we could go the same way like I already mentioned in some previous examples:</p>
<pre><code class="swift">// Only renaming `T.Type` into `Metatype<T>`
let const1: Metatype<T> = T
let const2: T = T()
let const3: T = T.init()
let const4: SomeOtherType = T.staticMember
// My vision
let const1: Type<T> = T
let const2: T = T()
let const3: T = T.init()
let const4: SomeOtherType = T.staticMember
</code></pre>
<p>I asked the community if’s possible to make current <code>T.Type</code> conform to <code>Hashable</code> protocol. The response was positive, because this would be really handy. </p>
<p>Such a change would need more compiler magic or an internal protocol which I believe isn’t the best way to solve this. There I come up with the idea wrapping the metatype into a type called <code>Type<T></code> and make the <em>public</em> <code>T.self</code> notation construct an instance of <code>Type<T></code> instead.</p>
<blockquote>
<p>Allow <code>Type<Type<T>></code></p>
</blockquote>
<p>Already possible with our current <code>Type<T></code>.</p>
<blockquote>
<p><strong>Extend <code>Mirror</code></strong> for Swift 4 </p>
</blockquote>
<p>Maybe, but I would still tackle the proposal for <code>Type<T></code>. Maybe we’ll find a solution which will suit everyone.</p>
<p>PS:</p>
<ul>
<li>I’m updating your last gist and preparing two refactored up (possible) implementation.</li>
<li>I’ll need a few hours, because I’m not that fast. :)</li>
<li>Stay patient.</li>
</ul>
<p></p></div><div class="bloop_original_html"><style>body{font-family:Helvetica,Arial;font-size:13px}</style><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div> <br> <div id="bloop_sign_1468660071891723008" class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">-- <br>Adrian Zubarev<br>Sent with Airmail</div></div></div><div class="bloop_markdown"><p></p></div></body></html>