[swift-evolution] Type based reference cycle detection
Darko Damjanovic
darkodamjanovic at me.com
Sun Feb 28 12:26:28 CST 2016
> class A { let myP: P? }
>
> class P { let myX: AnyObject? }
>
> Should this code generate a cycle warning? What if myP's type is
> GreatGreatGreatGrandParentOfP? Should any two class with a strong reference to
> AnyObject generate a warning?
Of course not. Extending the attempt to solve reference cycles in all special cases like inherited types, protocols, generics (is an Array<P> a P?) etc... would lead immediately to the thought "this is not possible to solve in a clean way“. And I think it would be true.
In my experience in app development almost 100% of all reference cycles where caused by the most simple form. And I don't have hard statistical data about it, just my own experience. But let's assume that 80% of all strong reference cycles during app development are in this simple form. Or just 50%. Wouldn't it still be great to have a warning in 50% of all possible strong reference cycles even if not all other cases are considered?
- Darko
More information about the swift-evolution
mailing list