[swift-evolution] Epic: Typesafe calculations

David Sweeris davesweeris at mac.com
Thu Jan 21 16:59:28 CST 2016


I made a post vaguely similar to that on the Apple dev forums, but I don't think I said anything about it here.

Basically I wanted to be able to define "List" and "Vector" as copies of Array, so that I could overload + for them and not worry about ambiguous code.

- Dave Sweeris

> On Jan 21, 2016, at 14:14, Erica Sadun via swift-evolution <swift-evolution at swift.org> wrote:
> 
> I vaguely remember having the discussion on this so the compiler could catch, for example:
> 
> typealias MyQuantityType = Int
> typealias MyCounterType = Int
> 
> let x: MyQuantityType = 2
> let y: MyCounterType = 3
> 
> x something blah something y // COMPILER ERROR
> 
> -- E
> 
> 
>> On Jan 21, 2016, at 2:58 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> 
>>> on Thu Jan 21 2016, Erica Sadun <swift-evolution at swift.org> wrote:
>>> 
>>> Going off the top of my head, I'd imagine it's a product type that
>>> inherits memory layout, code reuse, and conformances but introduces a
>>> distinct type for type safety checks.
>> 
>> FWIW, that's definitely not what *I'm* talking about, though some of the
>> people in this thread may have meant that.
>> 
>> -Dave
>> 
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution


More information about the swift-evolution mailing list