oop - In Racket's class system, what do augment, overment, augride, etc. do? -
racket's documentation partially describe augment , pubment do: augment makes method executes after superclass's version of method, while pubment makes method implicitly have augment property if defined in child class.
the docs absolutely nothing overment , augride, , can't guess based on names. they, , difference between them?
the relatively large family of inheritance functions racket's class system is, describe, little confusing, , cutesy names don't help.
in order understand this, racket provides 2 separate mechanisms method inheritance.
publicmethods correspond classical idea of public methods in other oo models. methods declaredpublicmay overridden in subclasses, unless they're declared final, in case cannot.pubmentmethods similar, cannot overridden, augmented. augmenting method similar overriding it, dispatch calls superclass's implementation instead of subclass's.
to clarify difference between overriding , augmentation, when overridden method called, overriding implementation executed, may optionally call superclass's implementation via inherit/super. in contrast, in augmented method, superclass's implementation receives control, , may optionally call subclass's implementation via inner.
now, we're provided public-final, override-final, , augment-final. these pretty simple. declaring method public-final means can neither augmented nor overridden. using override-final overrides superclass's public method, doesn't allow further overriding. finally, augment-final similar, methods declared pubment, not public.
so then, 2 weird hybrids, overment , augride?
overmentcan used implement methods initially definedpublic. "converts" them augmentable methods instead of overridable methods class's subclasses.augridegoes in opposite direction. converts augmentable method 1 overridable, overriding implementations replace augmentation, not original implementation.
to summarize:
public,pubment, ,public-finaldeclare methods not exist in superclass.- then have family of forms extending superclass methods:
override,augmentextend methods declaredpublic,pubment, respectively, using relevant behaviors.override-final,augment-finalsame non-final counterparts, prevent further overriding or augmentation.overment,augrideconvert overridable methods augmentable ones , vice-versa.
for another, fuller explanation, might interested in taking @ the paper racket's model derived, quite readable , includes helpful diagrams.
Comments
Post a Comment