I was wondering if it's possible to achieve the Hiding mechanism in Squeak, similar to the one in languages like C++ and C#, where its one of the main features. I know that I can override methods in Squeak and that I can't overload methods because its a dynamic languages, but Is it possible to hide methods/fields? I tried to dig in the Squeak logs but I could not find the answer. If it is possible to achieve hiding in Squeak I would be glad to see an example. If it's possible, what could be the reason? Maybe some OOP value which prohibits it?
-
1While there is no explicit syntax that prohibits a call to super, if you don't call super from a method override, then the inherited implementation is effectively hidden. And, no, you can't prevent a subclass from having access to the superclass instance variables. – James Foster Jul 02 '19 at 19:42
-
@JamesFoster your comment is actually an answer. Please promote it. – Leandro Caniglia Jul 03 '19 at 14:04
2 Answers
While there is no explicit syntax that prohibits a call to super, if you don't call super from a method override, then the inherited implementation is effectively hidden. And, no, you can't prevent a subclass from having access to the superclass instance variables.

- 2,070
- 10
- 15
Please read first @JamesFoster's answer.
It should be relatively easy to add support for disallowing super
. As super
is not always valid, or at least it shouldn't be when the superclass is nil
(e.g., ProtoObject
), the compiler should somewhere check for this condition before allowing super
as a valid pseudo variable. Then it would be a matter of tweaking that check by asking the class whether it supports super
or not (rather than whether its superclass is nil
).
I've tried in Pharo and there is no check at all (meaning that you can send to super
in ProtoObject
). So, modifying the Pharo compiler could be a little harder.

- 14,495
- 4
- 29
- 51