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.

  • public methods correspond classical idea of public methods in other oo models. methods declared public may overridden in subclasses, unless they're declared final, in case cannot.
  • pubment methods 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?

  • overment can used implement methods initially defined public. "converts" them augmentable methods instead of overridable methods class's subclasses.
  • augride goes in opposite direction. converts augmentable method 1 overridable, overriding implementations replace augmentation, not original implementation.

to summarize:

  • public, pubment, , public-final declare methods not exist in superclass.
  • then have family of forms extending superclass methods:
    • override , augment extend methods declared public , pubment, respectively, using relevant behaviors.
    • override-final , augment-final same non-final counterparts, prevent further overriding or augmentation.
    • overment , augride convert 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

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -