[swift-evolution] [Proposal Draft] Literal Syntax Protocols

Ben Rimmington me at benrimmington.com
Mon Jun 27 10:39:43 CDT 2016


> On 27 Jun 2016, at 14:37, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
> 
> DictionaryLiteral seems fine to me; it's as much a dictionary as ArrayLiteral is an array, right?

The `DictionaryLiteral` *structure* isn't a hash table.
It's an array of key-value pairs, and allows duplicate keys.
Entries are accessed by their position, not by their key.
<https://developer.apple.com/reference/swift/dictionaryliteral>

> What's wrong with ExtendedGraphemeCluster? It precisely self-documents what must exist between the double quotes to qualify as such a literal. Plus, we don't have e.g. a single-quoted character type; the name CharacterLiteral is a misnomer for what's effectively a string literal constrained by length.

The `ExtendedGraphemeCluster` prefix is verbose.
The `Character` *structure* is already defined as:
"A single extended grapheme cluster, ..."
Why have different names for the same concept?
<https://developer.apple.com/reference/swift/character>

> Likewise, it's not a StringInterpolationLiteral but StringInterpolation; there's no syntax for demarcating it, so it's a string literal constrained by what's between the double quotes.

The design team suggested `InterpolatedStringLiteral` in their SE-0041 feedback.
<https://github.com/apple/swift-evolution/blob/master/proposals/0041-conversion-protocol-conventions.md#response-to-design-team-feedback>

I suggested using protocol inheritance.
<http://article.gmane.org/gmane.comp.lang.swift.evolution/17229>

-- Ben


More information about the swift-evolution mailing list