>
> 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.
<not serious>
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? ;-)
</not serious>
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution