<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>I’m not in a rush. Right now I’m just bike shedding here and there. The problem with <code>typealias</code> I see is, that it really is a type alias and not a new type I’d want it to be. Or am I wrong here?</p>
<p>I’m curious what some of the core team would say on something like <code>typealias GenericProto<T> = Proto where P == T</code>.</p>
<p>Regarding existentials, yes that way it feels really redundant. To be honest, I see existentials like <code>Any<Collection where …></code> as a constrained interface I’d want to use somewhere. But existentials are not protocols to which I could conform to right?!</p>
<p>The main problem existentials solve is when you loose some constrain on a class or when you want to combine different protocols together. </p>
<pre><code class="swift">typealias MyConstrainedClassType = Any<BaseClassType, SomeProtocol where … >
typealias MyConstrainedExistential = Any<SomeProtocol, SomeOtherProtocol where … >
</code></pre>
<p>But what if I want to constrain a single protocol so that it creates a new protocol which is parameterized?</p>
<pre><code class="swift">protocol Foo {
associatedtype F
func workWith(_ f: F)
}
// These are interfaces but not new protocols right?!
typealias ExistentialIntFoo = Any<Foo where F == Int>
typealias ExistentialFoo<T> = Any<Foo where F == T>
// VS:
// These 'could' produce new protocols to which you could conform to
// (like SE-0142) or one could use these as interfaces (redundant with existentials)
typealias IntFoo = Foo where F == Int
typealias GenericFoo<T> = Foo where F == T
// Multiple conformances would be allowed this way `GenericFoo<Int> != GenericFoo<String>`
protocol Proto : GenericFoo<Int>, GenericFoo<String> {}
// What about merging?
typealias MergedFoos = GenericFoo<String> & GenericFoo<Int>
// Would this be equivalent to something like:
protocol MergedFoos : /* correct base protocol??? */ {
func workWith(_ f: Int)
func workWith(_ f: String)
}
</code></pre>
<p><code>typealias</code> could be so much powerful if you only imagine something like this:</p>
<pre><code class="swift">protocol Boo {
associatedtype B
func execute(_ b: B)
}
typealias Combined1 = Any<Foo, Boo where F == Int, B == String>
typealias Combined2 = Foo & Boo where F == Int, B == String
// There was a discussion about using `&` instead of `,`
protocol New : Foo, Boo where F == Int, B == String {}
// vs:
protocol New : Combined2 {}
class Base {}
class A : Base, Boo { func execute(_ b: Int) }
class B : Base, Boo { func execute(_ b: String) }
typealias BaseAndBoo = Any<Base, Boo>
typealias BaseAndBoo = Base & Boo
let baseAndBoo: BaseAndBoo = A() // or B()
typealias BaseAndIntBoo = Any<Base, Boo where B == Int>
typealias BaseAndIntBoo = Base & Boo where B == Int
let baseAndIntBoo: BaseAndIntBoo = A()
</code></pre>
<p>I kinda like the latter, because it either creates a new protocol or a new class, to which you can conform or inherit from. Plus it’s less <code>Any<></code> noise. </p>
<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_1481018872472055808" 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 6. Dezember 2016 um 10:33:25, 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">
<div class="markdown-here-wrapper" style="">
<p style="margin:0px 0px 1.2em!important">What makes me worry is if
this syntax is really the best one possible:</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);background-color:rgb(248,248,248);border-radius:3px;display:inline;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-keyword" style="color:rgb(51,51,51);font-weight:bold">typealias</span> <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">ConstructibleFrom</span><<span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">V</span>> = <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">ConstructibleFromValue</span> <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">where</span> <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">ValueType</span> == <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">V</span>
</code></pre>
<p style="margin:0px 0px 1.2em!important">I find it strange that
such exact line with <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);background-color:rgb(248,248,248);border-radius:3px;display:inline">
typealias</code> and <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);background-color:rgb(248,248,248);border-radius:3px;display:inline">
where</code> is required. I was hoping for an expression that lets
us specialize a protocol and use it in-place, like so:</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);background-color:rgb(248,248,248);border-radius:3px;display:inline;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-class"><span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">extension</span> <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">MyType</span> : <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">ConstructibleFromValue</span><<span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">ValueType</span> == <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">V</span>>
<span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">extension</span> <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">MyType</span> : (<span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">ConstructibleFromValue</span> <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">where</span> <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">ValueType</span> == <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">V</span>)</span>
</code></pre>
<p style="margin:0px 0px 1.2em!important">Also I thought that this
topic does not really belong to generalized existentials:</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);background-color:rgb(248,248,248);border-radius:3px;display:inline;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-keyword" style="color:rgb(51,51,51);font-weight:bold">var</span> x: <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">ConstructibleFrom</span><<span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Float</span>>
</code></pre>
<p style="margin:0px 0px 1.2em!important">I mean, we specify all
the types here, so the compiler should just specialize the protocol
and use it as a normal existential. The only thing that does not
allow us to do that now is syntax.<br>
By comparison, the following <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);background-color:rgb(248,248,248);border-radius:3px;display:inline">
typealias</code> does require generalized existentials, because
some <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);background-color:rgb(248,248,248);border-radius:3px;display:inline">
associatedtype</code>s, including <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);background-color:rgb(248,248,248);border-radius:3px;display:inline">
Iterator</code>, are not specified:</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);background-color:rgb(248,248,248);border-radius:3px;display:inline;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-keyword" style="color:rgb(51,51,51);font-weight:bold">typealias</span> <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">GenericCollection</span><<span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">E</span>> = <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Collection</span> <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">where</span> <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Iterator</span>.<span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Index</span> == <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Int</span>, <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Element</span> == <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">E</span>
</code></pre>
<p style="margin:0px 0px 1.2em!important">It also shows that future
generalized-existentials syntax will likely be exactly the same as
the one we choose now for protocol specialization.<br>
So we still should think twice before proceeding. We can implement
this proposal now, but do we want to?</p>
<div title="MDH:V2hhdCBtYWtlcyBtZSB3b3JyeSBpcyBpZiB0aGlzIHN5bnRheCBpcyByZWFsbHkgdGhlIGJlc3Qg b25lIHBvc3NpYmxlOjxkaXY+PGJyPjwvZGl2PjxkaXY+YGBgc3dpZnQ8L2Rpdj48ZGl2PnR5cGVh bGlhcyBDb25zdHJ1Y3RpYmxlRnJvbSZsdDtWJmd0OyA9IENvbnN0cnVjdGlibGVGcm9tVmFsdWUg d2hlcmUgVmFsdWVUeXBlID09IFY8L2Rpdj48ZGl2PmBgYDwvZGl2PjxkaXY+PGJyPjwvZGl2Pjxk aXY+SSBmaW5kIGl0IHN0cmFuZ2UgdGhhdCBzdWNoIGV4YWN0IGxpbmUgd2l0aCBgdHlwZWFsaWFz YCBhbmQgYHdoZXJlYCBpcyByZXF1aXJlZC4gSSB3YXMgaG9waW5nIGZvciBhbiBleHByZXNzaW9u IHRoYXQgbGV0cyB1cyBzcGVjaWFsaXplIGEgcHJvdG9jb2wgYW5kIHVzZSBpdCBpbi1wbGFjZSwg bGlrZSBzbzo8L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2P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Rpdj48ZGl2PmBgYHN3aWZ0PC9kaXY+PGRpdj50eXBlYWxpYXMgR2VuZXJpY0NvbGxl Y3Rpb24mbHQ7RSZndDsgPSBDb2xsZWN0aW9uIHdoZXJlIEl0ZXJhdG9yLkluZGV4ID09IEludCwg RWxlbWVudCA9PSBFPC9kaXY+PGRpdj5gYGA8L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2Pkl0IGFs c28gc2hvd3MgdGhhdCBmdXR1cmUgZ2VuZXJhbGl6ZWQtZXhpc3RlbnRpYWxzIHN5bnRheCB3aWxs IGxpa2VseSBiZSBleGFjdGx5IHRoZSBzYW1lIGFzIHRoZSBvbmUgd2UgY2hvb3NlIG5vdyBmb3Ig cHJvdG9jb2wgc3BlY2lhbGl6YXRpb24uPC9kaXY+PGRpdj5TbyB3ZSBzdGlsbCBzaG91bGQgdGhp bmsgdHdpY2UgYmVmb3JlIHByb2NlZWRpbmcuIFdlIGNhbiBpbXBsZW1lbnQgdGhpcyBwcm9wb3Nh bCBub3csIGJ1dCBkbyB3ZSB3YW50IHRvPzxicj48L2Rpdj4=" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0">
</div>
</div>
</div>
</div></div></span></blockquote></div><div class="bloop_markdown"><p></p></div></body></html>