[swift-evolution] 100% bikeshed topic: DictionaryLiteral
brent at architechies.com
Tue Jan 9 23:22:30 CST 2018
> On Jan 9, 2018, at 9:04 PM, Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org> wrote:
> The problem is that this isn't currently expressible in the type system. If we can, I would actually support including some kind of unprincipled private hack so we could say `where Element: _AnyTupleOfTwo`.
Sorry, I meant to provide an alternative but forgot.
If we can't do this, I think we should call it something like `PairArray` or `KeyValueArray` and augment its API to bring it closer to parity with `Array`. This type really does have the same semantics as `Array`—integer-indexed, order-preserving, random-access, etc.—and I think we should leverage that fact to make its behavior clear.
`PairArray` sort of vaguely suggests that we should have a `public typealias Pair<K, V> = (key: K, value: V)` in the standard library. I think that's actually a good idea, because we can use it to make sure that we use tuple element labels consistently across various APIs.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution