> On 29 Nov 2016, at 16:55, Aron Lindberg via swift-evolution 
> <[email protected]> wrote:
> 
> While I agree with most of your points Dave, I think forgetting to call super 
> is very much a (hard to debug) real world problem today.

I don’t. I’ve done it a few times but I don’t remember ever having a hard time 
debugging it.


> Especially new developers seems unsure or likely to forget to call super when 
> it is required.
> 
> I think my point is this; When you subclass code you have not written 
> yourself you have no idea if the class you are subclassing is "poorly 
> designed" and you should call super somewhere in your documentation. You can 
> make assumptions, read the documentation or use trial and error, but there is 
> no way to be certain unless the documentation is specific about it.

There’s a fine line between being a safe language and being as nannying 
language and I think proposals about “must call super” and “must not call 
super” overstep the line - that’s just my opinion, of course.

> 
> I went over the documentation for UIViewController. Is contains:
> - 11 functions that specify that your subclass must call super during the 
> implementation.
> - 2 functions where the documentation specifies the default implementation is 
> empty.
> - 2 functions where you must not call super.
> - 8 functions where you properly want to call super.
> - 23 functions where I think there is no need to call super.

Well that selection should tell us that whether you warn/error for not calling 
super or warn/error for calling super the decision is going to be the wrong one 
in some cases.

Also, the two functions where you must not call super are really two functions 
that you must override. After all, if the subclass fails to override the 
functions its implementation is going to call super by default, thus breaking 
the rule.


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

Reply via email to