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

T.J. Usiyan griotspeak at gmail.com
Tue May 17 23:13:43 CDT 2016


I've been thinking about the "conversion to some other type from this
protocol" case for a while since it often seems to go against the guidance
to add a property for this conversion. `Convertible` is always an awkward
Protocol to write, in my opinion.

Is there a chance that we simplify the the `Convertible` case by adding
this syntax to protocols

``` swift

protocol CustomStringConvertible {
    String.init(customStringFrom:)
}

```

or something similar? I admit that it *is* unwieldy to declare that String
has an initializer in a protocol *but* we almost always end up writing an
initializer which accepts our protocol and calls the 'constructor property'
we've required in the protocol. This removes that indirection (also
removing the strange two-ways-in-our-API-to-convert-this-to-that) and,
maybe, avoids some overloading.

On Mon, May 16, 2016 at 10:33 AM, Tony Allevato via swift-evolution <
swift-evolution at swift.org> wrote:

> On Tue, May 10, 2016 at 11:48 AM Chris Lattner via swift-evolution <
> swift-evolution at swift.org> wrote:
>
>> Hello Swift community,
>>
>> The review of "SE-0041: Updating Protocol Naming Conventions for
>> Conversions" begins now and runs through May 16. The proposal is available
>> here:
>>
>>
>> https://github.com/apple/swift-evolution/blob/master/proposals/0041-conversion-protocol-conventions.md
>>
>> Reviews are an important part of the Swift evolution process. All reviews
>> should be sent to the swift-evolution mailing list at
>>
>>         https://lists.swift.org/mailman/listinfo/swift-evolution
>>
>> or, if you would like to keep your feedback private, directly to the
>> review manager.
>>
>> What goes into a review?
>>
>> The goal of the review process is to improve the proposal under review
>> through constructive criticism and contribute to the direction of Swift.
>> When writing your review, here are some questions you might want to answer
>> in your review:
>>
>>         * What is your evaluation of the proposal?
>>
>
> +1 with the newly proposed Initializable/Representable names.
> Initializable just fits perfectly with the fact that Swift has things
> called initializers and is a vast improvement over Creatable. Representable
> to denote the other direction makes sense compared to existing Cocoa APIs
> that use *Representation in their name.
>
>
>>         * Is the problem being addressed significant enough to warrant a
>> change to Swift?
>>
>
> Yes. Many developers use stdlib as guidance when designing their own APIs
> and having the standard library be internally consistent sets a good
> example. These recommendations should also be hoisted into the API naming
> guidelines documentation so that people can easily cite it, as opposed to
> just saying "note the pattern that exists" (this is helpful when writing
> team-specific style guides and for enforcing conventions in code reviews).
>
>
>>         * Does this proposal fit well with the feel and direction of
>> Swift?
>>
>
> Yes, it makes the language more consistent.
>
>
>>         * If you have used other languages or libraries with a similar
>> feature, how do you feel that this proposal compares to those?
>>
>
> None that handle conversions in this way using protocols.
>
>
>>         * How much effort did you put into your review? A glance, a quick
>> reading, or an in-depth study?
>>
>
> I read the proposal, the message with the updated names afterwards, and
> loosely followed the e-mail threads.
>
>
>>
>> More information about the Swift evolution process is available at
>>
>>         https://github.com/apple/swift-evolution/blob/master/process.md
>>
>> Thank you,
>>
>> -Chris Lattner
>> Review Manager
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160518/d18b5db0/attachment.html>


More information about the swift-evolution mailing list