<div dir="ltr">I wrote some code tonight to experiment with this kind of thing. I apologize if it's off-topic for the thread, but it might be useful to others who want to experiment. <div><br></div><div><p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(145,145,145);background-color:rgb(68,68,68);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(145,145,145);background-color:rgb(68,68,68)"><span style="">//: Playground - noun: a place where people can play</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style="color:rgb(194,52,155)">import</span><span style=""> Cocoa</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(194,52,155);background-color:rgb(68,68,68)"><span style="">infix</span><span style="color:rgb(255,255,255)"> </span><span style="">operator</span><span style="color:rgb(255,255,255)"> • { </span><span style="">precedence</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(139,132,207)">180</span><span style="color:rgb(255,255,255)"> }</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(194,52,155);background-color:rgb(68,68,68)"><span style="">infix</span><span style="color:rgb(255,255,255)"> </span><span style="">operator</span><span style="color:rgb(255,255,255)"> → { </span><span style="">associativity</span><span style="color:rgb(255,255,255)"> left </span><span style="">precedence</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(139,132,207)">70</span><span style="color:rgb(255,255,255)"> }</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(194,52,155);background-color:rgb(68,68,68)"><span style="">infix</span><span style="color:rgb(255,255,255)"> </span><span style="">operator</span><span style="color:rgb(255,255,255)"> … { </span><span style="">associativity</span><span style="color:rgb(255,255,255)"> right </span><span style="">precedence</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(139,132,207)">60</span><span style="color:rgb(255,255,255)"> }</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style="color:rgb(194,52,155)">func</span><span style=""> → <T>( lhs: </span><span style="color:rgb(0,175,202)">Bool</span><span style="">, rhs: </span><span style="color:rgb(0,175,202)">T</span><span style=""> ) -> </span><span style="color:rgb(0,175,202)">T</span><span style="">? {</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style=""><span class="" style="white-space:pre">        </span></span><span style="color:rgb(194,52,155)">return</span><span style=""> lhs ? rhs : </span><span style="color:rgb(194,52,155)">nil</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style="">}</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style="color:rgb(194,52,155)">func</span><span style=""> … <T>( lhs:</span><span style="color:rgb(0,175,202)">T</span><span style="">?, rhs:</span><span style="color:rgb(0,175,202)">T</span><span style=""> ) -> </span><span style="color:rgb(0,175,202)">T</span><span style=""> {</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style=""><span class="" style="white-space:pre">        </span></span><span style="color:rgb(194,52,155)">return</span><span style=""> lhs != </span><span style="color:rgb(194,52,155)">nil</span><span style=""> ? lhs! : rhs</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style="">}</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style="color:rgb(194,52,155)">func</span><span style=""> depends<I,O>( dep:</span><span style="color:rgb(0,175,202)">I</span><span style="">, </span><span style="color:rgb(194,52,155)">_</span><span style=""> closure: (</span><span style="color:rgb(0,175,202)">I</span><span style="">)->(</span><span style="color:rgb(0,175,202)">O</span><span style="">) ) -> </span><span style="color:rgb(0,175,202)">O</span><span style=""> {</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style=""><span class="" style="white-space:pre">        </span></span><span style="color:rgb(194,52,155)">return</span><span style=""> closure( dep )</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style="">}</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style="color:rgb(194,52,155)">func</span><span style=""> • <I,O>( lhs: </span><span style="color:rgb(0,175,202)">I</span><span style="">, rhs: (</span><span style="color:rgb(0,175,202)">I</span><span style="">)->(</span><span style="color:rgb(0,175,202)">O</span><span style="">) ) -> </span><span style="color:rgb(0,175,202)">O</span><span style=""> {</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style=""><span class="" style="white-space:pre">        </span></span><span style="color:rgb(194,52,155)">return</span><span style=""> </span><span style="color:rgb(147,200,106)">depends</span><span style="">( lhs, rhs )</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style="">}</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(145,145,145);background-color:rgb(68,68,68)"><span style="">/* Example using "depends" */</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(194,52,155);background-color:rgb(68,68,68)"><span style="">let</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style=""><span class="" style="white-space:pre">        </span>str:</span><span style="color:rgb(0,175,202)">String</span><span style="">,</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style=""><span class="" style="white-space:pre">        </span>i = </span><span style="color:rgb(139,132,207)">7</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(147,200,106);background-color:rgb(68,68,68)"><span style="">str</span><span style="color:rgb(255,255,255)"> = </span><span style="">depends</span><span style="color:rgb(255,255,255)">( </span><span style="">i</span><span style="color:rgb(255,255,255)"> ){</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style=""><span class="" style="white-space:pre">        </span>$0==</span><span style="color:rgb(139,132,207)">2</span><span style=""> </span><span style="color:rgb(147,200,106)">→</span><span style=""> </span><span style="color:rgb(228,68,72)">"two"</span><span style=""> </span><span style="color:rgb(147,200,106)">…</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style=""><span class="" style="white-space:pre">        </span>$0==</span><span style="color:rgb(139,132,207)">3</span><span style=""> </span><span style="color:rgb(147,200,106)">→</span><span style=""> </span><span style="color:rgb(228,68,72)">"three"</span><span style=""> </span><span style="color:rgb(147,200,106)">…</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style=""><span class="" style="white-space:pre">        </span>$0==</span><span style="color:rgb(139,132,207)">4</span><span style=""> </span><span style="color:rgb(147,200,106)">→</span><span style=""> </span><span style="color:rgb(228,68,72)">"four"</span><span style=""> </span><span style="color:rgb(147,200,106)">…</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(228,68,72);background-color:rgb(68,68,68)"><span style="color:rgb(255,255,255)"><span class="" style="white-space:pre">        </span></span><span style="">"other"</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style="">}</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(145,145,145);background-color:rgb(68,68,68)"><span style="">/* Example using "•" operator as "depends" */</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style="color:rgb(194,52,155)">enum</span><span style=""> People { </span><span style="color:rgb(194,52,155)">case</span><span style=""> Kurtz, Popescu, Lime, Martins }</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style="color:rgb(194,52,155)">enum</span><span style=""> Order { </span><span style="color:rgb(194,52,155)">case</span><span style=""> First, Second, Third, Unknown }</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(194,52,155);background-color:rgb(68,68,68)"><span style="">let</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style=""><span class="" style="white-space:pre">        </span>order:</span><span style="color:rgb(147,200,106)">Order</span><span style="">,</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style=""><span class="" style="white-space:pre">        </span>person:</span><span style="color:rgb(147,200,106)">People</span><span style=""> = .</span><span style="color:rgb(147,200,106)">Lime</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(147,200,106);background-color:rgb(68,68,68)"><span style="">order</span><span style="color:rgb(255,255,255)"> = </span><span style="">person</span><span style="color:rgb(255,255,255)"> </span><span style="">•</span><span style="color:rgb(255,255,255)"> {</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(147,200,106);background-color:rgb(68,68,68)"><span style="color:rgb(255,255,255)"><span class="" style="white-space:pre">        </span>$0 </span><span style="">==</span><span style="color:rgb(255,255,255)"> .</span><span style="">Kurtz</span><span style="color:rgb(255,255,255)"> </span><span style="">→</span><span style="color:rgb(255,255,255)"> .</span><span style="">First</span><span style="color:rgb(255,255,255)"> </span><span style="">…</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(147,200,106);background-color:rgb(68,68,68)"><span style="color:rgb(255,255,255)"><span class="" style="white-space:pre">        </span>$0 </span><span style="">==</span><span style="color:rgb(255,255,255)"> .</span><span style="">Popescu</span><span style="color:rgb(255,255,255)"> </span><span style="">→</span><span style="color:rgb(255,255,255)"> .</span><span style="">Second</span><span style="color:rgb(255,255,255)"> </span><span style="">…</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(147,200,106);background-color:rgb(68,68,68)"><span style="color:rgb(255,255,255)"><span class="" style="white-space:pre">        </span>$0 </span><span style="">==</span><span style="color:rgb(255,255,255)"> .</span><span style="">Lime</span><span style="color:rgb(255,255,255)"> </span><span style="">→</span><span style="color:rgb(255,255,255)"> .</span><span style="">Third</span><span style="color:rgb(255,255,255)"> </span><span style="">…</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(147,200,106);background-color:rgb(68,68,68)"><span style="color:rgb(255,255,255)"><span class="" style="white-space:pre">        </span>.</span><span style="">Unknown</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68)"><span style="">}</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(68,68,68);min-height:12px"><span style=""></span><br></p><div><div><div><br></div><div><div>I also have some trepidation about posting it here, because it might have bugs. I wans't sure what "precedence" and "associativity" should be, for example. But it does make it more convenient to test alternative characters for operators, etc.</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Apr 9, 2016 at 12:05 AM, Vladimir.S via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class=""><br>
On 09.04.2016 9:31, Brent Royal-Gordon wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
This design is still very much under development—it hasn't even been reviewed, let alone added to the language. Here's the draft proposal:<<a href="https://github.com/jtbandes/swift-evolution/blob/case-enumerable/proposals/0000-derived-collection-of-enum-cases.md" rel="noreferrer" target="_blank">https://github.com/jtbandes/swift-evolution/blob/case-enumerable/proposals/0000-derived-collection-of-enum-cases.md</a>><br>
<br>
I'm not saying that this will necessarily be a solution that ends up being accepted—I'm merely saying that yes, it's something people are thinking about and designing; it's just been inactive for a few weeks.<br>
</blockquote>
<br></span>
Oh, I see. Thank you for letting know. Just missed "you would be able" in your previous message, did read it as "you are able", so was trying to find this in current Swift version. OK, glad to know that most likely we'll have improvements in enums eterations for Swift 3.0.<div class=""><div class="h5"><br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</div></div></blockquote></div><br></div></div>