All,
How does one enforce finality of methods in Squeak?
I noticed that methods like Object>>basicSize have instructions in comments not to override these, but what if these methods do get overridden/extended during compilation (perhaps by accident or oversight).
Can we use a dummy primitive in these methods to mark them as final?
Regards .. Subbu
Hi Subbu,
you cannot. :-) That's a good thing.
As you mentioned, you can document the specific role of a particular method to inform the programmer about side effects. Also, you can add tests that check for such "contracts" in the system. Well, for really dangerous stuff, there might be a hard-coded guard in compiler class. Yet, such guards can easily be overruled by custom compilers.
Best, Marcel Am 04.03.2019 02:16:38 schrieb K K Subbu kksubbu.ml@gmail.com: All,
How does one enforce finality of methods in Squeak?
I noticed that methods like Object>>basicSize have instructions in comments not to override these, but what if these methods do get overridden/extended during compilation (perhaps by accident or oversight).
Can we use a dummy primitive in these methods to mark them as final?
Regards .. Subbu
On 2019-03-04, at 8:49 AM, Marcel Taeumel marcel.taeumel@hpi.de wrote:
Hi Subbu,
you cannot. :-) That's a good thing.
Exactly. There is no possible reason to adopt such a ridiculous idea from lesser languages.
tim -- tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim A fool and his money are soon partying
On Mon, Mar 4, 2019 at 2:16 AM K K Subbu kksubbu.ml@gmail.com wrote:
All,
How does one enforce finality of methods in Squeak?
I noticed that methods like Object>>basicSize have instructions in comments not to override these, but what if these methods do get overridden/extended during compilation (perhaps by accident or oversight).
Can we use a dummy primitive in these methods to mark them as final?
There is no way to enforce this from inside the method, since if it is overridden in a subclass, the VM never even looks at that method.
We do warn users about accidentally overriding some methods, in particular anything defined in Behavior / ClassDescription / Metaclass. This works simply by having the browser check if the method you're trying to accept is "scary" (see isScarySelector:).
We could do something similar for methods that you really should not override (like #basicSize, #== etc).
- Bert -
On 3/4/19, Bert Freudenberg bert@freudenbergs.de wrote:
On Mon, Mar 4, 2019 at 2:16 AM K K Subbu kksubbu.ml@gmail.com wrote:
All,
How does one enforce finality of methods in Squeak?
I noticed that methods like Object>>basicSize have instructions in comments not to override these, but what if these methods do get overridden/extended during compilation (perhaps by accident or oversight).
Can we use a dummy primitive in these methods to mark them as final?
There is no way to enforce this from inside the method, since if it is overridden in a subclass, the VM never even looks at that method.
We do warn users about accidentally overriding some methods, in particular anything defined in Behavior / ClassDescription / Metaclass. This works simply by having the browser check if the method you're trying to accept is "scary" (see isScarySelector:).
We could do something similar for methods that you really should not override (like #basicSize, #== etc).
+1
- Bert -
squeak-dev@lists.squeakfoundation.org