[swift-evolution] private(call) and internal(call)

Michel Fortin michel.fortin at michelf.ca
Tue Jan 12 12:50:29 CST 2016


Le 11 janv. 2016 à 19:53, Charles Srstka via swift-evolution <swift-evolution at swift.org> a écrit :

> What do you think?

The idea looks good to me on the surface. But the details are awkward.

First, if you can't call the super implementation from an override, there is no need to require that the overriding function be private(call) because all it will contain is client code that can't call the library's implementation. So the derived class can make the function more visible by reimplementing it.

But that's not the common case. In general you want to allow the overriding function to call the super implementation. So...

Second, if you allow a call to the super implementation from an override, then you need to make that overriding function uncallable by anyone. Only the base class can call it using virtual dispatch. You can't call it even from the same file, so it's *less visible than private*.

That's a bit weird.

-- 
Michel Fortin
https://michelf.ca



More information about the swift-evolution mailing list