<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 2016-07-12, at 20:26, Chris Lattner via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><div class=""><div class="">The review of "SE-0121: Remove `Optional` Comparison Operators" begins now and runs through July 19. The proposal is available here:<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0121-remove-optional-comparison-operators.md" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0121-remove-optional-comparison-operators.md</a><br class=""></div></div></blockquote><br class=""><blockquote type="cite" class=""><div class=""><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>* What is your evaluation of the proposal?<br class=""></div></div></blockquote><div><br class=""></div><div>If SE-0123 is accepted, then I don’t mind keeping optional comparisons. But I also wouldn’t protest much against removing them until Optional can be made to conditionally conform to Comparable.</div><div><br class=""></div><div>If SE-0123 is rejected, then definitely +1; I’ve been bitten several times by accidentally using these while handling the return value of Collection’s index(of:).</div><div><br class=""></div><div>I don’t remember ever intentionally using these overloads, except ironically:</div><div><br class=""></div><div><a href="https://twitter.com/lorentey/status/657254631660236800" class="">https://twitter.com/lorentey/status/657254631660236800</a></div><div><br class=""></div><div>Note though that I often find myself wishing for Optional to implement Comparable. Writing comparison methods for little one-off Comparable structs that wrap Optionals gets tiring after a while. (As the proposal states, the existing overloads fall far short of achieving conditional conformance. I guess I could use these operators in the implementation of my wrapper structs, but I forget they exist.)</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>* Is the problem being addressed significant enough to warrant a change to Swift?<br class=""></div></div></blockquote><div><br class=""></div><div>This depends on the outcome of SE-0123, which aims to eliminate the pitfall that makes these overloads dangerous. </div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>* Does this proposal fit well with the feel and direction of Swift?<br class=""></div></div></blockquote><div><br class=""></div><div>I think Optional should implement Comparable whenever the wrapped type does. The proposal is a distinct step back from this. On the other hand, if SE-0123 fails, I think it’s worth giving up on this goal in favor of removing a common pitfall.</div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>* If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?<br class=""></div></div></blockquote><div><br class=""></div><div>Languages with implicit optionals do allow comparisons. E.g., "NSNotFound < 42" produces no compiler diagnostic. </div><div><br class=""></div><div>C++ has recently gained std::optional, which does provide </<=/>/>= operators, with the same semantics as Swift, including support for comparing optionals with non-optionals. It also has implicit promotion of values to optionals.</div><div><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3672.html#rationale.relops" class="">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3672.html#rationale.relops</a></div><div><br class=""></div><div>Rust’s std::Option<T> enum implements the std::cmp::Ord trait when T does. So Rust’s optionals are (conditionally) comparable. I believe Rust provides no implicit coercion from T to std::Option<T>, but to be honest I’m not entirely sure.</div><div><a href="https://doc.rust-lang.org/std/option/enum.Option.html#method.cmp" class="">https://doc.rust-lang.org/std/option/enum.Option.html#method.cmp</a></div><div><br class=""></div><div>So the few languages I know that support explicit optionals also make them comparable.</div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>* How much effort did you put into your review? A glance, a quick reading, or an in-depth study?<br class=""></div></div></blockquote><div><br class=""></div><div>Quick reading and minimal research.</div><div><br class=""></div><div>-- </div><div>Karoly</div><div>@lorentey</div><div><br class=""></div></div></body></html>