<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 Mar 7, 2016, at 15:17, Joe Groff <<a href="mailto:jgroff@apple.com" class="">jgroff@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><br class=""><blockquote type="cite" class="">On Mar 7, 2016, at 2:26 PM, Radosław Pietruszewski via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class="">-1, never seen a real world situation where this would be confusing/problematic.<br class=""><br class="">Having one operator is nice for chaining:<br class=""><br class="">var value = someArray ?? someFallback ?? secondaryFallback ?? []<br class=""></blockquote><br class="">This case could be handled by making `??` right-associative. In fact, I had originally implemented it that way. I don't recall why we changed it and added the extra overload; Jordan, do you recall?<br class=""></div></div></blockquote><br class=""></div><div>'??' doesn't <i class="">have</i> to fold all the optionals. I consider that a feature and am happy we have it; others may disagree.</div><br class=""><div class="">When there <i class="">is</i> a non-optional case at the end, the two versions are equivalent; they just build different intermediate closures.</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">(((someArray ?? someFallback) ?? secondaryFallback) ?? []) // left-associative</div><div class="">(someArray ?? (someFallback ?? (secondaryFallback ?? []))) // right-associative</div></blockquote><div class=""><br class=""></div><div class="">If 'someFallback' is the first non-nil argument, then in both cases 'someArray' and 'someFallback' will be evaluated and 'secondaryFallback' and '[]' will not. With the left-associative version, we have to do extra tests for nil, but those will be optimized away when ?? is inlined. We also create more closure instances, but again we can probably optimize that away. With the right-associative version, we end up with nested closures instead, which may be harder to optimize…or may not be.</div><div class=""><br class=""></div><div class="">Jordan</div><div class=""><br class=""></div></body></html>