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

Nate Cook nate at natecook.com
Wed Jun 29 16:59:10 CDT 2016




Nate
> On Jun 28, 2016, at 3:57 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
>> on Thu Jun 23 2016, Nate Cook <swift-evolution at swift.org> wrote:
>> 
>> I like the namespace-based approach to group these protocols together
>> and I'm very happy to see some clarification happening in this group
>> of protocols. However, I don't think the proposed new names
>> communicate what they need to. The names listed in the "Alternatives
>> Considered" section do a better job of describing the use and behavior
>> of these protocols.
>> 
>> Primarily, the new names read like we're saying that a conforming type
>> is a literal, compounding a common existing confusion between literals
>> and types that can be initialized with a literal.
> 
> No, it's exactly the opposite, as I keep saying.  Conformance to this
> protocol does *not* mean you can initialize the type with a literal.

Fair enough! The point I'm most concerned about is that there is confusion (among the populace at large, less so on this list) between literals and types that can be written as literals. The number 43 is an integer literal, not an `Int` - its type is either inferred from context or given explicitly. Some kind of adjective in the protocol name would make that more clear than removing the adjective.

> Proof:
> 
>  func f<T: IntegerLiteralConvertible>() -> T {
>    return T(integerLiteral: 43) // Error
>    return T(43)                 // Also an Error
>  }
> 
> It means an instance of the type can be *written* as a literal:
> 
>  func f<T: IntegerLiteralConvertible>() -> T {
>    return 43   // OK
>  }
> 
> Everybody's confused about the meaning of the protocol, and doesn't like
> the proposed names because they imply exactly the actual meaning of the
> protocol, which they misunderstand.

I resemble this remark.

Nate

> -- 
> Dave
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list