Re: [swift-evolution] [Discussion] What is the future of tuples in Swift?

2017-03-03 Thread Adrian Zubarev via swift-evolution
That’s what conditional conformances are made for in my opinion. The generics manifesto shows an example of equatable tuples iff every type is also equatable. That said, one probably should be able to extend a specific set of tuples to arithmetic operations if there is a need for that in your

Re: [swift-evolution] [Discussion] What is the future of tuples in Swift?

2017-03-03 Thread Stephen Canon via swift-evolution
> On Mar 3, 2017, at 7:57 AM, Adrian Zubarev via swift-evolution > wrote: > > The question here is, how is a tuple different from a mathematical vector? I > wasn’t referring to vector concepts from other languages, but used the > keyword vector to indicate a

Re: [swift-evolution] [Discussion] What is the future of tuples in Swift?

2017-03-03 Thread Adrian Zubarev via swift-evolution
The question here is, how is a tuple different from a mathematical vector? I wasn’t referring to vector concepts from other languages, but used the keyword vector to indicate a shortcut that provides a fixed or an arbitrary length such as …T would do in variadic generics context. A shortcut

Re: [swift-evolution] [Discussion] What is the future of tuples in Swift?

2017-03-03 Thread Tino Heth via swift-evolution
> I think that tuples should remain what they are now. Static-length vectors > should be types on their own and interact with tuples, with structs and with > Array<…> in the same way. > I strongly agree: Fixed-size vectors are a well known and simple concept that shouldn't be conflated with

Re: [swift-evolution] [Discussion] What is the future of tuples in Swift?

2017-03-02 Thread Matthew Johnson via swift-evolution
Sent from my iPad > On Mar 2, 2017, at 6:56 PM, Tony Allevato via swift-evolution > wrote: > > newtype feels like a leaky abstraction. Since the new type carries all the > protocol conformance and members of the original type, in your example, I > could add or

Re: [swift-evolution] [Discussion] What is the future of tuples in Swift?

2017-03-02 Thread Tony Allevato via swift-evolution
newtype feels like a leaky abstraction. Since the new type carries all the protocol conformance and members of the original type, in your example, I could add or divide RecordIds; but if they're database concepts, why would I want to do that? If the original type were extended to add members or

Re: [swift-evolution] [Discussion] What is the future of tuples in Swift?

2017-03-02 Thread Anton Zhilin via swift-evolution
2017-03-03 2:13 GMT+03:00 Slava Pestov : Does newtype add any new capability that’s not already covered by defining > a struct? > newtype would forward all members and conformances of the underlying type: newtype RecordId = Int let x: RecordId = 5let y = x + 10 extension

Re: [swift-evolution] [Discussion] What is the future of tuples in Swift?

2017-03-02 Thread Jaden Geller via swift-evolution
I’m not OP, but I imagine you can pattern match on the type. I don’t think that’s a compelling reason to add this feature though. I’d rather have active-patterns for structs. > On Mar 2, 2017, at 3:13

Re: [swift-evolution] [Discussion] What is the future of tuples in Swift?

2017-03-02 Thread Slava Pestov via swift-evolution
> On Mar 2, 2017, at 3:24 AM, Anton Zhilin via swift-evolution > wrote: > > I think that tuples should remain what they are now. Static-length vectors > should be types on their own and interact with tuples, with structs and with > Array<…> in the same way. > >

Re: [swift-evolution] [Discussion] What is the future of tuples in Swift?

2017-03-02 Thread Adrian Zubarev via swift-evolution
Actually the generics manifesto has a nice solution on how we could extend tuples in the future. Parameterized extensions + variadic generics could allow us a lot. I played with a simple sketch on how it could be enhanced. Especially I personally like the ability of fixed vs. unbound parameter

Re: [swift-evolution] [Discussion] What is the future of tuples in Swift?

2017-03-02 Thread Anton Zhilin via swift-evolution
I think that tuples should remain what they are now. Static-length vectors should be types on their own and interact with tuples, with structs and with Array<…> in the same way. newtype should be what enables extension of tuples: newtype Money = (Int, Int) extension Money:

[swift-evolution] [Discussion] What is the future of tuples in Swift?

2017-03-01 Thread Adrian Zubarev via swift-evolution
Hi Swift community, I’d love to discuss with you the future of tuples in Swift. I’m really curious whether tuples will ever evolve beyond their current state or not. Last year we revamped custom operators with a whole new syntax in Swift, so why don’t we start a discussion on how tuples could