<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I think an important point is that `all<>` should NOT be restricted to having only one reference or value type!</div><div class=""><br class=""></div><div class="">Ceylon does not have any restrictions like that. You can form the type intersection of String and Integer for example, which are both classes in Ceylon and because Ceylon like Swift only knows single inheritance between classes, the result is simply `Nothing` (the bottom type which has no elements). So there is no need to forbid this explicitly, because the types work out just fine.</div><div class=""><br class=""></div><div class="">Furthermore you can form type intersections between reference types which inherit from each other. The resulting intersection type is valid and is just equal to the more specific type. And of course you can form type intersections of a reference or value type with itself (i.e. all<SomeClass, SomeClass>).</div><div class=""><br class=""></div><div class="">Why should that be useful you may ask?</div><div class=""><br class=""></div><div class="">This generality is important when using intersection types with generics: let’s consider the type of a function forming the intersection of two sets with different element types:</div><div class=""><br class=""></div><div class="">func union<T, U>(a: Set<T>, b: Set<U>) -> Set<all<T, U>> { … }</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Requiring all<T,U> to have at most one reference or value type (which must be at first position) would impose some unnecessary restrictions:</div><div class=""><br class=""></div><div class="">Given the following:</div><div class=""><br class=""></div><div class="">protocol Named {}</div><div class="">class Person : Named {}</div><div class="">class Employee : Person {}</div><div class=""><br class=""></div><div class="">let people: Set<Person></div><div class="">let otherPeople: Set<Person></div><div class="">let employees: Set<Employee></div><div class="">let namedOnes: Set<Named></div><div class=""><br class=""></div><div class="">// unnecessary restriction:</div><div class="">let x1 = union(namedOnes, people) // not allowed, because result type contains all<Named, Person> </div><div class=""><br class=""></div><div class="">// the restriction would require us to write:</div><div class="">let x2 = union(people, namedOnes) // ok, result type would be Set<all<Person, Named>> which would be simplified by the compiler to Set<Named> (Ceylon does this!)</div><div class=""><br class=""></div><div class="">// unnecessary restriction:</div><div class="">let x3 = union(people, employees) // not allowed, because result type would contain all<Person, Employee> with two reference types</div><div class=""><br class=""></div><div class="">// unnecessary restriction</div><div class="">let x4 = union(people, otherPeople) // not allowed, because result type contains all<Person, Person> with two reference types</div><div class=""><br class=""></div><div class="">IMO these should all be allowed (and are possible in Ceylon). </div><div class="">The result type of x1 would be Set<all<Named, Person>> which would be simplified by the compiler to Set<Named>.</div><div class="">The result type of x2 would be Set<all<Person, Named>> which would be simplified by the compiler to Set<Named>.</div><div class="">The result type of x3 would be Set<all<Person, Employee>> which would be simplified by the compiler to Set<Employee>.</div><div class="">The result type of x4 would be Set<all<Person, Person>> which would be simplified by the compiler to Set<Person>.</div><div class=""><br class=""></div><div class="">-Thorsten</div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">Am 14.05.2016 um 01:50 schrieb Adrian Zubarev via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>>:</div><br class="Apple-interchange-newline"><div class=""><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class="">If anyone is interested, I started a draft proposal with detailed design here: <a href="https://github.com/DevAndArtist/swift-evolution/blob/master/proposals/nnnn-merging-types-with-protocols.md" class="">https://github.com/DevAndArtist/swift-evolution/blob/master/proposals/nnnn-merging-types-with-protocols.md</a></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class="">I didn’t post it here, because it is a bit huge and could lose its markdown formats. `all<>` is always bold, because this is what we are interested in, but I provided all possible combinations if the other formats would exists (at least all combinations I could think of, anything else is derived from these). </div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class="">`class<>` etc. can be seen as a future direction (I would say), otherwise this would easily become out of scope for Swift 3. (I will move `class<>` etc. from detailed design to future direction later.)</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class="">I’d love to hear your feedback and strong arguments for the motivation part I could include into this proposal.</div><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div id="bloop_sign_1463182837742214912" class="bloop_sign" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="font-family: helvetica, arial; font-size: 13px;" class="">-- <br class="">Adrian Zubarev<br class="">Sent with Airmail</div></div><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><p class="airmail_on" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Am 13. Mai 2016 bei 23:16:20, Vladimir.S (<a href="mailto:svabox@gmail.com" class="">svabox@gmail.com</a>) schrieb:</p><blockquote type="cite" class="clean_bq" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span class=""><div class=""><div class=""></div><div class="">You asked for any example, I give it to you ;-)<span class="Apple-converted-space"> </span><br class="">(as I said, it is syntactical, just to show that such struct<> can be used<span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span><br class="">to test some struct for conforming to protocol, that was not conformed at<span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span><br class="">writing time)<span class="Apple-converted-space"> </span><br class="">Probably we can invent useful examples for this struct<> - but I don't<span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span><br class="">believe it will be introduced in Swift ;-)<span class="Apple-converted-space"> </span><br class=""><br class="">On 13.05.2016 22:14, Adrian Zubarev via swift-evolution wrote:<span class="Apple-converted-space"> </span><br class="">> Can we really do that? I mean, I thought about that myself but I came to<span class="Apple-converted-space"> </span><br class="">> the conclusion that this scenario is like: I was to lazy to couple this<span class="Apple-converted-space"> </span><br class="">> structs to my library protocols, will you do that for me?<span class="Apple-converted-space"> </span><br class=""></div></div></span></blockquote><span style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span></div></blockquote></div><br class=""></body></html>