[swift-evolution] [swift-evolution-announce] [Review] SE-0089: Replace protocol<P1, P2> syntax with Any<P1, P2>

Brent Royal-Gordon brent at architechies.com
Wed May 25 14:22:36 CDT 2016


> But if we are going to remove the ability to use typealiases bound to `Any` in constraints we need to introduce an alternative mechanism for factoring out constraints (hopefully a superior mechanism that can abstract over constraints that relate generic parameters to each other).

I could certainly imagine having, for instance, a `constraintalias` keyword:

	constraintalias HashableAndComparable = Hashable, Comparable
	constraintalias CollectionOfConforming<ElementConstraint> = Collection where .Element: ElementConstraint

	let value: Any<HashableAndComparable> = 123
	
	func sum<C: CollectionOfConforming<Integer>>(numbers: C) -> C.Iterator.Element {
		return numbers.reduce(0, combine: +)
	}

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list