[swift-evolution] 100% bikeshed topic: DictionaryLiteral

Gwendal Roué gwendal.roue at gmail.com
Tue Jan 9 11:45:55 CST 2018


> Le 9 janv. 2018 à 18:18, Nate Cook <natecook at apple.com> a écrit :
> 
>> On Jan 9, 2018, at 11:00 AM, Gwendal Roué via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>>> 
>>> Le 9 janv. 2018 à 17:16, Zach Waldowski via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> a écrit :
>>> 
>>> I'm not sure a valid use case by a third party makes it hold its weight for inclusion in the stdlib.
>> 
>> You're definitely right, and that's why I wrote with the most humble tone I could.
>> 
>> Yet, the design of the stdlib *requires* some speculation about use cases, and speculation is *helped* by the exposition of actual uses. I'm not sure readers of the mailing list had any idea of the use cases of the current DictionaryLiteral, and maybe I helped a little.
>> 
>>> Reproducing its feature set is extremely trivial, and would probably allow you to hint the implementation details better for your use case.
>> 
>> Please define "trivial”.
>> 
>> In case anybody would wonder, in the line below the `row` variable is of type Row which happens to adopt ExpressibleByDictionaryLiteral. It is not of type DictionaryLiteral. The use case here is the ability to express a row with a dictionary literal that accepts duplicated keys and preserves ordering:
>> 
>> 	XCTAssertEqual(row, ["a": 1, "a": 2])
> 
> That’s great! In this case you aren’t using the DictionaryLiteral type, but a “dictionary literal”, which no one is suggesting we remove.

You're right ! I was almost sure that ExpressibleByDictionaryLiteral initializer would eat a DictionaryLiteral, but it doesn't!

	extension Row : ExpressibleByDictionaryLiteral {
		init(dictionaryLiteral elements: (String, DatabaseValueConvertible?)...) { ... }
	}

This code has been written too long ago. I have been mislead, I'd like to apologize.

> If I’m understanding what you wrote, this is another case where the terrible name is making it super hard to discuss what we’re talking about. “Dictionary literals” and the ExpressibleByDictionaryLiteral protocol are safe!

Yes, I have been bitten hard by the names! Time for bikeshedding indeed :-)

Gwendal

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20180109/95076f80/attachment.html>


More information about the swift-evolution mailing list