[swift-evolution] [swift evolution] [proposal] Proposal to add "implement" keyword to denote protocol method implementation

Victor Gao victorgao44 at gmail.com
Sat Mar 19 08:18:48 CDT 2016


Do I need to create a md file in the swift evolution repository to post my proposal?

> On Mar 19, 2016, at 00:12, Jordan Rose <jordan_rose at apple.com> wrote:
> 
> [+swift-evolution] Sure! It's just a fancy word for doing something like this:
> 
> protocol SelfAppendable {
>   init()
>   func +=(other: Self)
> }
> 
> func *<Sequence: SelfAppendable >(sequence: Sequence, count: Int) -> Sequence {
>   var result = Sequence()
>   for _ in 0..<count {
>     result += sequence
>   }
>   return result
> }
> 
> extension Array: SelfAppendable {}
> extension String: SelfAppendable {}
> 
> Both Array and String already have no-argument initializers and a += function, but they come from the standard library and don't (necessarily) satisfy any protocols, so they wouldn't be declared "implement". I can think of a few different ways to deal with this, but mostly I just want to make sure you (and everyone else) are considering this use case in your proposal. :-)
> 
> Best,
> Jordan
> 
>> On Mar 18, 2016, at 17:04 , Victor Gao <victorgao44 at gmail.com <mailto:victorgao44 at gmail.com>> wrote:
>> 
>> Hi Jordan,
>> 
>> Could you explain more of what retroactive modeling is and how it affects the proposal? I am unfamiliar with retroactive modeling. Thanks!
>> 
>> Victor Gao.
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160319/7edfe368/attachment.html>


More information about the swift-evolution mailing list