<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 7, 2015, at 12:38 PM, Colin Barrett <<a href="mailto:colin@springsandstruts.com" class="">colin@springsandstruts.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 7, 2015, at 8:55 AM, Joe Groff <<a href="mailto:jgroff@apple.com" class="">jgroff@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 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 class=""><br class="Apple-interchange-newline">On Dec 6, 2015, at 1:14 PM, Jacopo Andrea Giola via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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;">Yes, I’m aware that at this time the reswitch can be abused and maybe can be better refined to disallow such cases.</div></div></blockquote><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 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=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 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="">Infinite reswitch loops seem useful. I'm thinking in particular of interpreter loops, where it's common to use GCC's computed goto extension when written in C.</div></div></blockquote><div class=""><br class=""></div>I agree that they have useful semantics; I just wonder if it’s more clear to have explicit recursion (with TCO ;) rather than to add a looping construct that effectively does the same thing...</div><div class=""><br class=""></div><div class="">Can’t lie though, given the lack of TCO in Swift, a keyword like this would probably mean fewer stack frames in code I’ve written myself (for instance, a parser combinator library).</div></div></div></blockquote><br class=""></div><div>Semantically they're equivalent, but you're putting more into the optimizer's hands than many would feel comfortable with. TCO notwithstanding, the naive CFG that results from a self-recursive call still funnels the switch dispatch jump into the top of the loop, which means you're sharing one branch predictor slot for every "reswitch". This is one of the main reasons computed goto exists in GCC instead of letting people just use 'switch x { }; unreachable()'. An explicit "reswitch" could emit the rebranch in-line at the reswitch point. </div><br class=""><div class="">-Joe</div></body></html>