[swift-evolution] 100% bikeshed topic: DictionaryLiteral
charlesism.com at gmail.com
Tue Jan 9 18:47:19 CST 2018
I used a DictionaryLiteral only yesterday, and it turned what would have a typically unreadable array of Structs into something much more elegant. I'm pretty sure the only reason Literals (of all varieties) aren't used more often is because Swift programmers don't realize they are available and easy to implement.
Sent from my telephone
> On Jan 8, 2018, at 9:40 PM, Nevin Brackett-Rozinsky via swift-evolution <swift-evolution at swift.org> wrote:
>> On Mon, Jan 8, 2018 at 11:53 PM, Xiaodi Wu via swift-evolution <swift-evolution at swift.org> wrote:
>> Thank you for the clarification. It occurred to me in the shower that this might be the case, and that I was entirely mistaken as to what we were talking about.
>> Yes, then, I wholeheartedly agree on this point. Out of curiosity, why are there source stability issues to 'typealias DictionaryLiteral<Key, Value> = [(Key, Value)]'?
> Because at the point of use, “DictionaryLiteral” is instantiated with an actual dictionary literal, eg. “[a: 1, b: 2, c: 3]”, and that syntax isn’t available for an array of key-value pairs. As near as I can tell, the convenience of that spelling is the entire raison-d’être for “DictionaryLiteral” in the first place.
> The ulterior question of whether preserving “DictionaryLiteral” is worthwhile, is apparently out of scope. Personally, I have a hard time imagining a compelling use-case outside of the standard library, and I doubt it’s being used “in the wild” (I checked several projects in the source-compatibility suite and found zero occurrences).
> swift-evolution mailing list
> swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution