Sorry, that's not my question, which doesn't involve protocols I don't own. Let 
me restate. Given three types I don't own as follows:

```
struct A : Frobnicate {
    override required func frobnicate() { print("A") } // "A", or delete to get 
default
}
struct B: Frobnicate {
    override required func frobnicate() { print("B") } // "B", or delete to get 
default
}
struct C: Frobnicate  { }
```

-- E


> On Apr 28, 2016, at 11:48 AM, Xiaodi Wu <[email protected]> wrote:
> 
> Sorry, that's not my question, which doesn't involve protocols I don't own. 
> Let me restate. Given three types I don't own as follows:
> 
> ```
> struct A {
>     func frobnicate() { print("A") }
> }
> struct B {
>     func frobnicate() { print("B") }
> }
> struct C { }
> ```
> 
> I want to conform them to a protocol of my own design, Frobnicatable, and 
> supply a default `frobnicate()`:
> 
> ```
> protocol Frobnicatable {
>     func frobnicate()
> }
> extension Frobnicatable {
>     func frobnicate() { print("Default") }
> }
> extension A: Frobnicatable { }
> extension B: Frobnicatable { }
> extension C: Frobnicatable { }
> 
> let c = C()
> c.frobnicate() // "Default"
> ```
> 
> (Yes, I realize there are issues regarding static and dynamic dispatch that 
> limit the utility of this particular example--let's leave those aside for 
> now.)
> Where would I affix keywords such as `required` and `override` to make this 
> work after implementation of your proposal?

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to