The relatively large family of inheritance functions for Racket's class system is, as you describe, a little confusing, and their somewhat cutesy names don't always help.
In order to understand this, Racket provides two separate mechanisms for method inheritance.
public
methods correspond to the classical idea of public methods in other OO models. Methods declared with public
may be overridden in subclasses, unless they're declared final, in which case they cannot.
pubment
methods are similar, but they cannot be overridden, only augmented. Augmenting a method is similar to overriding it, but the dispatch calls the superclass's implementation instead of the subclass's.
To clarify the difference between overriding and augmentation, when an overridden method is called, the overriding implementation is executed, which may optionally call the superclass's implementation via inherit/super
. In contrast, in an augmented method, the superclass's implementation receives control, and it may optionally call the subclass's implementation via inner
.
Now, we're also provided public-final
, override-final
, and augment-final
. These are pretty simple. Declaring a method with public-final
means it can neither be augmented nor overridden. Using override-final
overrides a superclass's public method, but it doesn't allow any further overriding. Finally, augment-final
is similar, but for methods declared with pubment
, not public
.
So then, what about the two weird hybrids, overment
and augride
?
overment
can be used to implement methods initially defined with public
. This "converts" them to augmentable methods instead of overridable methods for all the class's subclasses.
augride
goes in the opposite direction. It converts an augmentable method to one that is overridable, but the overriding implementations only replace the augmentation, not the original implementation.
To summarize:
public
, pubment
, and public-final
all declare methods that do not exist in a superclass.
- Then we have a family of forms for extending superclass methods:
override
and augment
extend methods declared with public
and pubment
, respectively, using the relevant behaviors.
override-final
and augment-final
do the same as their non-final counterparts, but prevent further overriding or augmentation.
overment
and augride
convert overridable methods to augmentable ones and vice-versa.
For another, fuller explanation, you might be interested in taking a look at the paper from which Racket's model was derived, which is quite readable and includes some helpful diagrams.