<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><div><blockquote type="cite" class=""><div class="">On 07 Apr 2016, at 19:16, Dave Abrahams via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><div class=""><br class=""><blockquote type="cite" class="">It would be nice to know the rationale behind the choice of the current syntax.<br class="">I agree that these seem more natural:<br class=""><br class=""> @warn_unused_result<br class=""> public func ~=<I : ForwardIndexType where I : Comparable>(value: I, pattern:<br class=""> Range<I>) -> Bool<br class=""><br class=""> @warn_unused_result<br class=""> public func ~=<I : IntervalType>(value: I.Bound, pattern: I) -> Bool<br class=""></blockquote><br class=""><span class="" style="float: none; display: inline !important;">+1</span><br class=""></div></blockquote><div><br class=""></div><div>This operator was firstly introduced in Swift in the form =~ but then it was reversed to the current form (~3y ago). There’s a little context about this change on Twitter: <a href="https://twitter.com/dmcrodrigues/status/717063623957471232" class="">https://twitter.com/dmcrodrigues/status/717063623957471232</a>.</div><br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">I would not change from `~=` to `=~` though.<br class=""></blockquote><br class=""><span class="" style="float: none; display: inline !important;">One downside with `~=` is that it reads like `+=`, which mutates the</span><br class=""><span class="" style="float: none; display: inline !important;">LHS. Of course, `=~` has its own issues, e.g. `x=~y` might read as `x =</span><br class=""><span class="" style="float: none; display: inline !important;">~y`.</span><br class=""></blockquote></div><br class=""><div class="">I agree but this operator already exists in other languages like Ruby and Perl, so align the syntax may be a good option.</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class="">On 07 Apr 2016, at 18:56, Erica Sadun <<a href="mailto:erica@ericasadun.com" class="">erica@ericasadun.com</a>> wrote:</blockquote><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><span class="" style="float: none; display: inline !important;">I'd prefer to offer both ~= and =~, allowing the consumer to choose which side the pattern sits on.</span></div></blockquote><br class=""></div><div class="">On the other hand, I like in particular the option of having both `~=` and `=~` to provide more flexibility like Erica has suggested. The main question is if that’s ok introduce another operator in the language.</div><div class=""><br class=""></div><div class="">— </div><div class="">David</div></div></body></html>