<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">Jacopo,</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">I have read your gist twice and try to think it over. I am afraid that I am not agree with you on this.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">I think maybe your code will be more readable if you change that from switch to if clause. Maybe like this:</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">var x= 0</div><div class="gmail_default" style="font-family:georgia,serif">var default = true</div><div class="gmail_default"><div class="gmail_default"><font face="georgia, serif">let array = [1, 2, 3];</font></div><div class="gmail_default"><font face="georgia, serif">var element = 1;</font></div><div class="gmail_default"><font face="georgia, serif"><br></font></div></div><div class="gmail_default" style="font-family:georgia,serif">if .One {</div><div class="gmail_default" style="font-family:georgia,serif">default = false</div><div class="gmail_default" style="font-family:georgia,serif">x = 10</div><div class="gmail_default" style="font-family:georgia,serif">}</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">if .Two && x >= 0 && x < array.count: {</div><div class="gmail_default" style="font-family:georgia,serif">default = false</div><div class="gmail_default"><font face="georgia, serif">element = array[x];</font><br></div><div class="gmail_default" style="font-family:georgia,serif">}</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">if .Three {</div><div class="gmail_default" style="font-family:georgia,serif">default = false</div><div class="gmail_default" style="font-family:georgia,serif">...</div><div class="gmail_default" style="font-family:georgia,serif">}</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">if default {</div><div class="gmail_default" style="font-family:georgia,serif">...</div><div class="gmail_default" style="font-family:georgia,serif">}</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">Comparing to the fallThrough with fallTo, I think the prior's code is more readable and more predictable. If I am someone who tries to read some other one's code. I can quickly read the switch part as it only goes with each case alone or goes with each case and the cases below them. If the switch is written with fallTo, then I have to draw a case-map myself, or I can't figure out what may really happens. Especially if there is some thing like </div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">case .One:</div><div class="gmail_default" style="font-family:georgia,serif">fallTo .Two:</div><div class="gmail_default" style="font-family:georgia,serif">case .Two:</div><div class="gmail_default" style="font-family:georgia,serif">fallTo .One:</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">That leads a infinite loop. Or make the switch case unpredictable.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">zhaoxin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 9, 2016 at 8:08 PM, Jacopo Andrea Giola 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>FYI I’ve updated the gist with the draft of the proposal, <a href="https://gist.github.com/JGiola/f735212789bf2f697847" target="_blank">https://gist.github.com/JGiola/f735212789bf2f697847</a></div><div>But I see that the discussion is pretty much death so I don’t know if it’s worth anymore to make an official request on the evolution repo…</div><div><br></div><div>- Jacopo</div><br><div><blockquote type="cite"><div>On 21 Dec 2015, at 22:41, Chris Lattner <<a href="mailto:clattner@apple.com" target="_blank">clattner@apple.com</a>> wrote:</div><br><div><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On Dec 21, 2015, at 11:57 AM, Jacopo Andrea Giola <<a href="mailto:swift-evolution@jacopo.giola.org" target="_blank">swift-evolution@jacopo.giola.org</a>> wrote:</div><br><div><div style="word-wrap:break-word"><div>Hi Chris,</div><div><br></div><div>well now after some debate in the old thread and the flaws highlighted there I’ve wrote e different proposal and narrowed the changes to only make fallthrough respect the where clause if present and to explicitly state the case where you want to fall.</div><div>This I think will improve the safety of the keyword and can further reduce hidden bugs in the keyword usage. The removing of fallthrough is in the title only because with the new behaviour the meaning in not correct anymore.</div><div>It can make sense?</div></div></div></blockquote><div><br></div><div>I’m not sure what you mean, but I’ll take a look at the other thread.</div><div><br></div><div>-Chris</div><br><blockquote type="cite"><div><div style="word-wrap:break-word"><div><br></div><div>- Jacopo</div><br><div><blockquote type="cite"><div>On 15 Dec 2015, at 22:32, Chris Lattner <<a href="mailto:clattner@apple.com" target="_blank">clattner@apple.com</a>> wrote:</div><br><div><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On Dec 15, 2015, at 1:03 AM, Jacopo Andrea Giola <<a href="mailto:swift-evolution@jacopo.giola.org" target="_blank">swift-evolution@jacopo.giola.org</a>> wrote:</div><br><div><div style="word-wrap:break-word"><div><div>Hi Chris,</div><div><br></div><div>sorry for bothering you, but during the festivity I finally have some time to work on the formal proposal draft and I’m trying to find where the switch and fallthrough behaviours are defined.</div><div>Can you point me in the right direction? I want to see if it is feasible and fill the "Detailed design” section of the proposal with something that has some sense and can be used as a reference on how to implement the new keyword if is accepted.</div></div></div></div></blockquote><div><br></div><div>Are you asking my opinion of the topic? There were two related things discussed in the thread:</div><div><br></div><div>1) removing fallthrough: I found the arguments personally unconvincing. I feel that removing fallthrough would make some important things much harder to express and uglier, potentially leading to buggier code. I also feel that the behavior of “fallthrough” is obvious even if you’re not familiar with it, so the reasons to remove ++/— and c-style-for don’t apply.</div><div><br></div><div>2) on adding reswitch: It’s an interesting extension, but very narrow in applicability, and purely syntactic sugar over what we have now. I don’t see a compelling reason to add it now, given the other higher priority things we need to make happen for swift 3.</div><div><br></div><div>-Chris</div><div><br></div><br><blockquote type="cite"><div><div style="word-wrap:break-word"><div><div><br></div><div>Thank you very much.</div><div><br></div><div>- Jacopo</div></div></div></div></blockquote></div></div></div></blockquote></div><br></div></div></blockquote></div><br></div></div></blockquote></div><br>
<img alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
</div>
<br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">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>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><br>Owen Zhao<br></div></div></div>
</div>