> On May 30, 2016, at 3:42 AM, Tino Heth via swift-evolution > <[email protected]> wrote: > >> I can't reply directly to all the points in this thread, but I will just say >> that there are ways of emulating protected in the language as it exists >> today: >> >> If the goal is to have functions that can be overridden by subclasses >> without being called by external classes, you can create a parameter of a >> public type with a private initializer and use it in all "protected" member >> functions. No external code will be able to call such functions because they >> cannot create an argument of the correct type. > As others stated before: > I agree it's a cool little hack, but a hack none the less — and imho it isn't > useful in real life. > The focus should be documenting intend ("this method should be used in a > certain way"). Creating clever countermeasures to stop users of a library to > enforce limitations is imho the wrong way.
Couldn’t you use the same reasoning to claim there shouldn’t be access control at all? Just add documention on methods you want to mark private telling users of the library not to call them! Charles
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
