[swift-evolution] Tuples as RawRepresentable

Haravikk swift-evolution at haravikk.me
Sat Oct 15 17:33:50 CDT 2016


> On 15 Oct 2016, at 18:21, Nevin Brackett-Rozinsky <nevin.brackettrozinsky at gmail.com> wrote:
> 
> Tuples cannot conform to protocols, so despite the existence of an “==” operator for certain tuples, no tuple conforms to Equatable.
> 
> This is problematic, because it means that a function which takes a generic Equatable parameter cannot be called with a tuple argument, even though an applicable “==” operator exists.
> 
> (Ditto for “Comparable”, mutatis mutandis.)
> 
> Nevin

Yeah, since the operators are implemented though perhaps some kind of magic can be used? It seems strange that the following is valid:

	struct Foo : Equatable { let value:(Int, Int) }
	func == (lhs:Foo, rhs:Foo) -> Bool { return lhs.value == rhs.value }

Yet tuples can't just be Equatable etc. But I'm wondering whether that falls into separate issue territory, such that it should be done first as its own proposal?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161015/e797139a/attachment.html>


More information about the swift-evolution mailing list