[squeak-dev] final methods

Bert Freudenberg bert at freudenbergs.de
Mon Mar 4 21:41:44 UTC 2019

On Mon, Mar 4, 2019 at 2:16 AM K K Subbu <kksubbu.ml at 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 -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20190304/a164346c/attachment.html>

More information about the Squeak-dev mailing list