[swift-evolution] [swift-evolution-announce] [Review] SE-0041: Updating Protocol Naming Conventions for Conversions

Dave Abrahams dabrahams at apple.com
Thu May 19 17:34:22 CDT 2016


on Wed May 18 2016, Erica Sadun <swift-evolution at swift.org> wrote:

>> On May 18, 2016, at 1:58 PM, Matthew Johnson via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> 
>>> On May 18, 2016, at 1:52 PM, Brent Royal-Gordon <brent at architechies.com> wrote:
>>> 
>
>>>>> If we're doing this, I wonder if category 1 shouldn't just be
>>>> `Convertible`. This would preserve our `LiteralConvertible`
>>>> protocols with the same names (which, consistency issues aside,
>>>> seem perfectly cromulent), while shifting the `StringConvertible`
>>>> protocols over to the `Representable` category.
>>>> 
>>>> Do you really think 'Convertible' is more clear than 'Initializable'?
>>> 
>>> I don't think `Convertible` is clearer than `Initializable`, but I
>>> think it rolls off the tongue better, is easier to spell, is more
>>> compatible with non-initializer implementations, and in general
>>> wins on a lot of squishy, subjective, hard-to-define axes.
>>> 
>>> Subjectively, I've noticed that a lot of people *don't* think of
>>> things like `Double(myFloat)` as being initializers; they think of
>>> them as conversions. To those people, `Convertible` is probably the
>>> right name.
>> 
>> Thanks for elaborating.  I can see that perspective.  It does also
>> have the advantage of being the smallest change from current state.
>> 
>> I certainly wouldn’t oppose this.  The most important thing IMO is that we agree on *something*.
>
> The whole discussion started because ArrayLiteralConvertible meant
> "can be initialized from Array literal", and not "can be converted to
> array literal", which is what nearly everyone this was presented to in
> an informal study thought it meant.

Actually, it means “can be the type of an array literal.”  An array
literal is an expression, not an object.  Roughly speaking, the type
checker decides what type the array literal has by finding the
best-matching type that conform to the protocol, and the code generator
injects the necessary calls to the initializer.

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

-- 
-Dave



More information about the swift-evolution mailing list