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

Matthew Johnson matthew at anandabits.com
Fri Jun 24 10:09:48 CDT 2016


Thanks for the feedback Adrian!

> On Jun 24, 2016, at 10:01 AM, Adrian Zubarev via swift-evolution <swift-evolution at swift.org> wrote:
> 
> I don’t like an underscore on public protocols. If we’re not forced to use the proposed syntax at all it looks strange when you use a type with an underscore (which to me represents something for private or internal usage).
> 
> 
The underscore is used in the same way it is used elsewhere in the standard library.  The protocols must be public because they need to be visible to user code in order for the design to work correctly.  However, they are considered implementation details that users really shouldn’t know about.  This pattern is well established in the standard library.

> In Swift we only can use literals for a single direction literal -> type, so why don’t we just rename the protocols to look like:
> 
> 
This is a reasonable suggestion.  I’ll add it to the alternatives section.
> public protocol NilLiteralProtocol { ... }
> public protocol BooleanLiteralProtocol { ... }
> public protocol FloatLiteralProtocol { ... }
> public protocol IntegerLiteralProtocol { ... }
> public protocol UnicodeScalarLiteralProtocol { ... }
> public protocol ExtendedGraphemeClusterProtocol { ... }
> public protocol StringLiteralLiteralProtocol { ... }
> public protocol StringInterpolationLiteralProtocol { ... }
> public protocol ArrayLiteralProtocol { ... }
> public protocol DictionaryLiteralProtocol { ... }
> Here Protocol corresponds to the user that we’re about to access a specific literal with our type which implements the protocol. (Just like ErrorProtocol.)
> - extension Array : ArrayLiteralConvertible
> + extension Array : ArrayLiteralProtocol
> 
> 
> 
> -- 
> Adrian Zubarev
> Sent with Airmail
> 
> Am 24. Juni 2016 um 16:21:21, Vladimir.S via swift-evolution (swift-evolution at swift.org <mailto:swift-evolution at swift.org>) schrieb:
> 
>> es are
> 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160624/942c4486/attachment.html>


More information about the swift-evolution mailing list