<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 13px;" class="">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:</span><div style="font-family: Helvetica; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 13px;" class=""><br class=""></div><div style="font-family: Helvetica; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 13px;" class="">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.</div></div></blockquote></div>As others stated before:<div class="">I agree it's a cool little hack, but a hack none the less — and imho it isn't useful in real life.</div><div class="">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.</div><div class="">&lt;not serious&gt;</div><div class="">We could even use tools like public key cryptography to secure access to APIs — or is there any developer who doesn't want to deal with more certificates? ;-)</div><div class="">&lt;/not serious&gt;</div><div class=""><br class=""></div></body></html>