[swift-evolution] Compile-time generic specialization

Abe Schneider abe.schneider at gmail.com
Fri Feb 10 12:15:59 CST 2017


>> protocol LinearOperations {
>>   associatedtype StorageType
>>   static func dot(_ lhs:Tensor<StorageType>, _
>> rhs:Tensor<StorageType>) -> Tensor<StorageType>
>>   ...
>> }
>>
>> extension Tensor: LinearOperations {
>> ...
>> }
>>
>> extension Tensor: LinearOperations where StorageType:CBlasStorage<Float> {
>> ...
>> }
>>
> I’m assuming that both of these extensions implement the static func dot(_:_:). This is more interesting direction for me, because it’s taking the existing notion of customization points via protocol requirements and extending that to also support some level of customization.

Exactly (sorry, I should've made that explicit). I'd be super happy if
this functionality got added to Swift.

Abe


More information about the swift-evolution mailing list