[swift-evolution] Proposals: (1) Forbidding custom `==` for value types, (2) `dispatch` keyword, (3) `default`-result for methods with `Self`, and (4) Poor-Mans-Existentials
Johannes Neubauer
neubauer at kingsware.de
Mon Jul 18 13:48:22 CDT 2016
> Am 18.07.2016 um 14:01 schrieb Johannes Neubauer via swift-evolution <swift-evolution at swift.org>:
>
>
>> Am 18.07.2016 um 13:52 schrieb Johannes Neubauer via swift-evolution <swift-evolution at swift.org>:
>>
>>>
>>> Am 18.07.2016 um 13:05 schrieb L. Mihalkovic <laurent.mihalkovic at gmail.com>:
>>>
>>> IMHO implementing your proposal would close the door on some of the things you do when building in-memory dbs (T == U -> TRUE for T not related to U), which if swift remains for small apps is not a terrible loss, but may be more of an issue for one day doing big-data with it.
>>
>> You talk about reference types now, right? I proposed a `default` keyword, which (in a pattern matching fashion) would catch all calls to T == U for which no implementation exists (so this is exactly when T != U). You could of course change for a given type hierarchy the `default` result to `true` if appropriate.
>
> This formulation can be misleading: I mean `a == b` where `a: T` and `b: U` and `T != U`. Due to dynamic dispatch even: `a.dynamicType == T && b.dynamicType == U && T != U`.
But I think, for such a radical different semantic than the normal interpretation of equality I think I wouldn’t use the `Equatable`-protocol at all, but implement a custom protocol with a custom operator.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160718/70d96cff/attachment.sig>
More information about the swift-evolution
mailing list