[swift-evolution] Proposals: (1) Forbidding custom `==` for value types, (2) `dispatch` keyword, (3) `default`-result for methods with `Self`, and (4) Poor-Mans-Existentials
Susan Cheng
susan.doggie at gmail.com
Fri Jul 15 20:53:38 CDT 2016
How about Polar(r: 0, phi: 0) ?
It should all equal with any angles if r == 0.
2016-07-16 0:41 GMT+08:00 Johannes Neubauer via swift-evolution <
swift-evolution at swift.org>:
>
> > Am 15.07.2016 um 18:29 schrieb Saagar Jha <saagarjha28 at gmail.com>:
> >
> > Here's a value type that uses custom equality (at least, I think so):
> String. Since it uses extended grapheme clusters, internally two Strings
> may be composed of different Unicode scalars, but if they create the same
> Characters they are considered to be equal.
>
> Good point. But shouldn’t this be another type of equality then or do they
> behave exactly the same and are just implemented differently? Because if
> not, this seems to be introducing mixed-type comparisons like `5l == 5` or
> `Point2D(0, 0) == Point3D(0, 0, 0) which are bad since they make it
> impossible to guarantee reflexivity, symmetry, and transitivity. Swift does
> a hard job to enforce this from the programmer. If this is really intended,
> then there should be a fixed implementation for equality of value types,
> which can be overridden, but which leads to a warning (which has to be
> suppressed with some kind of annotation or so). Because, these custom
> implementations can do harm.
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160716/0c30ddd6/attachment.html>
More information about the swift-evolution
mailing list