[swift-evolution] Make generics covariant and add generics to protocols

Thorsten Seitz tseitz42 at icloud.com
Thu Jan 14 16:37:10 CST 2016


> Am 14.01.2016 um 14:57 schrieb Matthew Johnson via swift-evolution <swift-evolution at swift.org>:
> 
> On Jan 14, 2016, at 2:39 AM, Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org> wrote:
> 
>>> It doesn't make the type system unsound; the types are mostly checked at compile time but some are runtime checked, either way the types are checked and therefore the type system is sound.
>> 
>> Runtime type checking is not an adequate replacement for compile-time type checking. Runtime type checking ensures your code does not continue to run if it encounters a type error; compile-time type checking ensures your code is *incapable of encountering* a type error. This is a bit like saying that it's okay to drive drunk because seatbelts and airbags will mitigate the injuries caused if you crash.
>> 
>> Swift has a lovely property where, if your code is typed strongly enough and compiles without errors, it's probably pretty close to working. I would hate to see that watered down.
> 
> +1.  Swift's type system is very well thought out.  It is going to get even better with the generics enhancements in Swift 3, removing many of the current limitations.  We are heading down the right path.  Changing course and introducing runtime checks where static checks are possible is a bad idea.

Big +1 from me!

-Thorsten


More information about the swift-evolution mailing list