|
|
|
|
|
by serpix
481 days ago
|
|
The compiler will not know if a protocol is not passed to a function expecting a protocol. Whereas a static typing language will not compile. Similarly nothing prevents invoking missing functions of a protocol, you will only know during runtime. |
|
The goal isn't to introduce .. a compilation step? but to have the program blow up in the spot where there is an type mismatch. If you don't use a protocol you may not blow up, you may generate a nil, and you may blow up much further down the line (or not at all)
In the rare instances where dynamic types cause problems, they're virtually always something convoluted like that. The protocol design pattern describes the interface and protects you from hard to debug situations