<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="">Swift already has a very useful goto operator that avoids the usual problems associated with arbitrary control flow. With labels and continue/break you can implement very complex control flow schemas, but still maintain structured code. I have used it at multiple occasions and this is something I absolutely adore about Swift.&nbsp;<div class=""><br class=""></div><div class="">— Taras</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 03 Jul 2016, at 03:27, Daryle Walker via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; 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=""><div class="">Rust and Ada (and probably others) have a iteration statement that specifically goes on forever, instead of using a convention of a “while”/“repeat-until”/“for" with a never-exiting test. &nbsp;It’s called “loop.” &nbsp;Would that be a good idea to add instead of continuing to use convention? &nbsp;(I don’t know if the compiler does infinite-loop optimization, or if it can detect it through a “while true” or similar convention.) &nbsp;Maybe we can label a function “@noreturn” (or whatever) if it ends with a loop that doesn’t have a jump statement in it (or flag an error for such loops).</div><div class=""><br class=""></div><div class="">Although some consider it harmful, should we add a “goto” statement? &nbsp;We would need to support labeling any statement, of course. &nbsp;Besides needing the destination label to be in the same innermost function block as the goto, what other gotchas (skipping initialization and/or destruction) do we have to watch for? &nbsp;How would it interact with “guard”? &nbsp;I would also propose a “goto LABEL case EXPRESSION,” where the LABEL marks a “switch” statement that surrounds the goto statement and reevaluates the switch with the new value. &nbsp;This would help with case jumping too complex for “fallthrough” to work (including jumping FROM a “default” case).</div><div class=""><br class=""></div><div class="">[I was going the ponder on generalizing the “zip2” stuff to more-than-two sources, but that requires variadic generics and other people have already got ideas for this.]</div><div class=""><br class=""></div><div class="">Should we have double (or multiple or predicate) dispatch added? &nbsp;Or course, both preferring methods to free functions and defining methods within types (especially classes and protocols) bias for single dispatch. &nbsp;We would have to switch back to preferring free functions or have some sort of “[object1, object2].myMethod” form of dispatch. &nbsp;And it would go beyond what Objective-C does (I think).</div><div class=""><br class=""></div><div class="">[OK, I saw “predicate dispatch” on Wikipedia while looking up multiple dispatch, and I don’t quite understand it (yet).]</div><div class=""><br class=""></div><div class="">When I read an article at &lt;<a href="http://www.cocoawithlove.com/blog/2016/02/16/use_it_or_lose_it_why_safe_c_is_sometimes_unsafe_swift.html" class="">http://www.cocoawithlove.com/blog/2016/02/16/use_it_or_lose_it_why_safe_c_is_sometimes_unsafe_swift.html</a>&gt;, I was surprised at Swift doesn’t make objects addressable by default. &nbsp;The C family assumes being able to do this, and therefore forfeits any optimizations from non-addressable objects. &nbsp;But I remembered that Ada also does this; you have to explicitly mark objects as addressable (with the “aliased” keyword). &nbsp;Should we allow users to mark objects, including blocks of objects, as always-addressable? &nbsp;Or keep addressability as automatic, via certain functions?</div><div class=""><br class=""></div><div class="">
<div style="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; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">—&nbsp;</div><div class="">Daryle Walker<br class="">Mac, Internet, and Video Game Junkie<br class="">darylew AT mac DOT com&nbsp;</div></div>
</div>
<br class=""></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>