<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>Okay I carefully read the gist and here is my feedback:</p>
<ul>
<li><p>First of all thank you for combining your thoughts with mine.</p></li>
<li><p>There is a small typo (SE–0090 is not accepted yet) - only in the first example:</p>
<pre><code class="swift">func unsafeBitCast<T, U>(_: T, to: U.Type)
unsafeBitCast(10, to: Double)
// The second line should be
unsafeBitCast(10, to: Double.self)
</code></pre></li>
<li><blockquote>
<p>Size and internal structure of Type<t> will be the same as of T.Type </t></p>
</blockquote>
<ul>
<li>Do we really need this to be the same?</li>
</ul></li>
<li><blockquote>
<p>Values of Type<t> store identifiers of U such that U: T.</t></p>
</blockquote>
<ul>
<li>Why would we want to store more than one unique identifier?</li>
</ul></li>
</ul>
<p>Actually I thought for a while about the negative effect of fully removing metatypes from the language. Metatypes allow us to build neat looking execution branches like showed in SE–0101.</p>
<pre><code class="swift">extension MemoryLayout<T> {
init(_ : @autoclosure () -> T) {}
public static func of(_ candidate : @autoclosure () -> T) -> MemoryLayout<T>.Type {
return MemoryLayout.init(candidate).dynamicType
}
}
// Value
let x: UInt8 = 5
MemoryLayout.of(x).size // 1
MemoryLayout.of(1).size // 8
MemoryLayout.of("hello").stride // 24
MemoryLayout.of(29.2).alignment // 8
</code></pre>
<p>I wouldn’t want to throw this away.</p>
<p>I played with the idea of keeping <code>T.Type</code> internally but disallow it in public declarations. Furthermore metatypes would still exist, but can only be instantiated through <code>Type<T>.metatype</code> or <code>Type<T>().metatype</code>.</p>
<p>To keep the neat designing feature but get rid of <code>T.Type</code> we could abuse generic typealiases here:</p>
<pre><code class="swift">// T.Type would be only visible here but is disallowed in public declarations
// in favor of `Metatype<T>`
public typealias Metatype<T> = T.Type
public struct Type<T> : Hashable, CustomStringConvertible, CustomDebugStringConvertible {
…
public var metatype: Metatype<T> { return Type<T>.metatype }
// Internally `.self` should be renamed to `.metatype` and return
// a metatype instance
public static var metatype: Metatype<T> { return T.metatype }
…
}
</code></pre>
<p>That way the sample from above won’t break from its designing point, but will require some refactoring:</p>
<pre><code class="swift">extension MemoryLayout<T> {
init(_ : @autoclosure () -> T) {}
public static func of(_ candidate : @autoclosure () -> T) -> Metatype<MemoryLayout<T>> {
return dynamicType(MemoryLayout.init(candidate)).metatype
}
}
</code></pre>
<p>I’m aware that we are moving <code>size</code> etc. into <code>Type</code> but the example I just used was to show that metatypes are still very useful in terms of designing neat looking apis.</p>
<p>That’s why I’d suggest that our proposal should tackle solving SE–0090, opening the door for reflections, combining SE–0101 and providing an easier implementation for SE–0096.</p>
<p>Internally the core team might rename <code>T.Type</code> to <code>T.Metatype</code> to sort out any confusion. And we still would migrate all public <code>T.Type</code> to use <code>Type<T></code> instead.</p>
<p>PS:</p>
<p>We should also mention that dynamic casts need some tweaking to work with <code>Type<T></code>.</p>
<p>And one more thing:</p>
<pre><code class="swift">public var size: Int { get }
public var stride: Int { get }
public var alignment: Int { get }
public static var size: Int { return Type<T>().size }
public static var stride: Int { return Type<T>().stride }
public static var alignment: Int { return Type<T>().alignment }
</code></pre>
<p>Shouldn’t these work exactly the opposite way? If in the future <code>Type<T></code> would be extended with reflection functionality and contain more stored properties, it would be lightweight to compute <code>size</code> etc. from static <code>size</code> without the need of instantiating the whole type.</p>
<pre><code class="swift">public var size: Int { return Type<T>.size }
public var stride: Int { return Type<T>.stride }
public var alignment: Int { return Type<T>.alignment }
public static var size: Int { get }
public static var stride: Int { get }
public static var alignment: Int { get }
</code></pre>
<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_1468516317609362176" 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 14. Juli 2016 um 12:39:05, Anton Zhilin (<a href="mailto:antonyzhilin@gmail.com">antonyzhilin@gmail.com</a>) schrieb:</p> <blockquote type="cite" class="clean_bq"><span><div><div></div><div>
<title></title>
<div dir="ltr">Plase take a look:
<div><a href="https://gist.github.com/Anton3/08a069a3b6f634bece7ad666922741d2">https://gist.github.com/Anton3/08a069a3b6f634bece7ad666922741d2</a></div>
<div class="gmail_extra"><br>
<div class="gmail_quote">2016-07-14 0:38 GMT+03:00 Adrian Zubarev
via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">
<div>
<p>I’m still not fully convinced about fully removing the access to
the metatype.</p>
<p>If you look at Ericas and Daves current proposal for
<code>MemoryLayout</code> it would completely break and it would
become impossible to build something like this.</p>
<p>And yes I borrowed the idea of putting properties like
<code>size</code> into <code>Type<T></code> from SE–0101.
That was mentioned in my previews posts.</p>
<p>If we remove <code>.Type</code>, how’d we access static members
in other types like <code>MemoryLayout<T></code>?</p>
<ul>
<li>This is another contra argument to consider.</li>
</ul>
<p><strong>@Erica @Dave</strong>: Any statement on our conversation
about <code>Type<T></code>?</p>
<p>I apologize that this whole idea raised in parallel to your
proposal.</p>
<p>PS: We can merge our ideas into a single formal proposal. Ping
me off-list when you get some time tomorrow.</p>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div></div></span></blockquote></div><div class="bloop_markdown"><p></p></div></body></html>