Question re: String.init(describing:) overloads: why there are four?

Hard to understand, but the compile error message makes this clear for me:

func funkyfunk<T: CustomStringConvertible>(_ v: T) {
    print(v.description)
}

funkyfunk(Foo() as CustomStringConvertible)     // <== compile error here

**error: value of protocol type 'CustomStringConvertible' cannot conform to 'CustomStringConvertible'; only struct/enum/class types can conform to protocols**

**funkyfunk(Foo() as CustomStringConvertible)**

**note: required by global function 'funkyfunk' where 'T' = 'CustomStringConvertible'**

**func funkyfunk<T: CustomStringConvertible>(_ v: T) {**

Rephrasing the first error message: Protocols cannot comform to protocols. Only struct/enum/class types can conform to protocols.

So with just a protocol type, Swift cannot call the specific appendInterpolation<Subject:...>(...), so it just call the unqualified generic one (the last one). There is no way to make string interpolation to call the specific one with just a protocol with common overloading.

But should work with specific call signature:

"\(csc: s1, default: "s1 is nil")"

(never mind, do not work with just protocol, still the same reason: protocol cannot conform to protocol)

I think it's clear now for me. :roll_eyes:

Also, all four appendInterpolation<Subject:...>(...) are needed in order to get the right specialized String.init(describing:)