<div dir="ltr"><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important">I suggested it because now we can’t call any initializers on <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">Type<T></code>. If we add <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">_Type<T></code>, we can add public initializers and keep <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">Type<T></code> instances unique.</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code class="hljs language-swift" style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248);white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248)"><span class="hljs-comment" style="color:rgb(153,153,136);font-style:italic">// No uniqueness guarantee</span>
internal final <span class="hljs-class"><span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">class</span> <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">_Type</span><<span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">T</span>> </span>{
<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">var</span> _metatype: <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Metatype</span><<span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">T</span>>
<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">init</span>()
<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">init</span>(<span class="hljs-number" style="color:rgb(0,128,128)">_</span>: <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">AnyMetatype</span>)
<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">init</span>?<<span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">U</span>>(casting: <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Type</span><<span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">U</span>>)
}
internal <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">var</span> _typeStorage = <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Set</span><_Type<<span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Any</span>>>()
<span class="hljs-comment" style="color:rgb(153,153,136);font-style:italic">// Uniqueness guarantee</span>
<span class="hljs-comment" style="color:rgb(153,153,136);font-style:italic">// 'final class' is an implementation detail</span>
public <span class="hljs-class"><span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">struct</span> <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">Type</span><<span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">T</span>> </span>{
internal <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">var</span> _impl: _Type<<span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">T</span>>
<span class="hljs-comment" style="color:rgb(153,153,136);font-style:italic">// Notice 'public'</span>
public <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">init</span>()
public <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">init</span>(<span class="hljs-number" style="color:rgb(0,128,128)">_</span>: <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">AnyMetatype</span>)
public <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">init</span>?<<span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">U</span>>(casting: <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Type</span><<span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">U</span>>)
}
</code></pre>
<p style="margin:0px 0px 1.2em!important">There will be no <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">===</code> operator for <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">Type<T></code>, because it does not add value. <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">Type<T></code> is a wrapper of typeless identifier with value semantics. It is singleton pattern that makes us use classes.</p>
<div title="MDH:PGRpdiBjbGFzcz0iZ21haWxfZXh0cmEiPkkgc3VnZ2VzdGVkIGl0IGJlY2F1c2Ugbm93IHdlIGNh
bid0IGNhbGwgYW55IGluaXRpYWxpemVycyBvbiBgVHlwZSZsdDtUJmd0O2AuIElmIHdlIGFkZCBg
X1R5cGUmbHQ7VCZndDtgLCB3ZSBjYW4gYWRkIHB1YmxpYyBpbml0aWFsaXplcnMgYW5kIGtlZXAg
YFR5cGUmbHQ7VCZndDtgIGluc3RhbmNlcyB1bmlxdWUuPC9kaXY+PGRpdiBjbGFzcz0iZ21haWxf
ZXh0cmEiPjxicj48L2Rpdj48ZGl2IGNsYXNzPSJnbWFpbF9leHRyYSI+YGBgc3dpZnQ8L2Rpdj48
ZGl2IGNsYXNzPS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