<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi Nikita,</div><div class=""><br class=""></div><div class="">See if the below implementation fits your needs:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class="">protocol<span style="color: #000000" class=""> P1 {}</span></div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class="">protocol<span style="color: #000000" class=""> P2 : </span><span style="color: #4f8187" class="">P1</span><span style="color: #000000" class=""> </span>where<span style="color: #000000" class=""> </span><span style="color: #703daa" class="">T</span><span style="color: #000000" class=""> : </span><span style="color: #4f8187" class="">P1</span><span style="color: #000000" class=""> {</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class="">&nbsp; &nbsp; </span>associatedtype<span style="color: #000000" class=""> T</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; <span style="color: #ba2da2" class="">var</span> input : <span style="color: #703daa" class="">T</span> { <span style="color: #ba2da2" class="">get</span> }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">struct</span> S1 : <span style="color: #4f8187" class="">P1</span> {}</div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">struct</span> S2 : <span style="color: #4f8187" class="">P2</span> {</div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class="">&nbsp; &nbsp; </span>typealias<span style="color: #000000" class=""> T = </span><span style="color: #4f8187" class="">S1</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; <span style="color: #ba2da2" class="">var</span> input: <span style="color: #4f8187" class="">T</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div></div><div class=""><br class=""></div><div class="">Regards,</div><div class="">Muthu</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 30 Aug 2017, at 1:25 AM, Nikita Leonov via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">Hello everyone,&nbsp;</span><div style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px;" class="">I am looking a way to express something similar to the following code in Swift terms:</div><div style="font-family: Helvetica; font-size: 12px;" class=""><div style="margin:0px;line-height:normal;font-family:Menlo" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(196,34,117)" class="">protocol</span><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp;AnyViewModelInput {}</span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(196,34,117)" class="">protocol</span><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp;AnyViewModel&lt;</span><span style="color:rgb(97,34,174)" class="">ViewModelInput&gt;</span><span style="font-variant-ligatures:no-common-ligatures" class="">:&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(97,34,174)" class="">ViewModelInput</span><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(196,34,117)" class="">where</span><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp;ViewModelInput: AnyViewModelInput {</span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(196,34,117)" class="">var</span><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp;input:&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(97,34,174)" class="">ViewModelInput</span><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp;{&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(196,34,117)" class="">get</span><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp;}</span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">}</span></div></div><div style="font-size: 12px; margin: 0px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; margin: 0px; line-height: normal;" class="">Is it possible in current Swift? Will it be possible if generic manifesto&nbsp;will be implemented in full? Also if you know how to express a similar idea in any other language, I would love to see examples. How does such construct is named in other languages?</div><div style="font-family: Helvetica; font-size: 12px; margin: 0px; line-height: normal;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; margin: 0px; line-height: normal;" class="">Thank in advance,</div><div style="font-family: Helvetica; font-size: 12px; margin: 0px; line-height: normal;" class="">Nikita</div></div>
_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></body></html>