Re: CLOS question



In article <joswig-453135.00094030072007@xxxxxxxxxxxxxxxxxxxxxxxx>,
Rainer Joswig <joswig@xxxxxxxxxxxxxx> wrote:

In article <1185746464.124847.288820@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Scott Burson <FSet.SLB@xxxxxxxxx> wrote:

On Jul 29, 2:27 pm, stam...@xxxxxxxx (Rob St. Amant) wrote:
I have what seems like a familiar CLOS question, but a quick Google
search doesn't turn up an answer: I have a method, m, and an after
method for it. The after method is specialized on class c. I'd like
to define a class d that inherits c, and have instances of d behave
just like instances of c *except* for that single after method.

This suggests to me that you have analyzed your domain incorrectly.
It would seem that D is not really a subclass of C if you don't want
it to inherit the full behavior of M.

Why that? Each more specific primary method blocks the
less specific primary method. Thus you are not inheriting
the whole functionality. Sure, you can call the next method,
but by default this is not done. Overwriting less specific
functionality is a capability provided for primary
methods. Just not for :before and :after methods. But those
were design decisions for the standard method combination.

IMHO, :BEFORE and :AFTER methods were created primarily to support the
mixin style of OO programming. If you don't want to inherit these
methods, you simply don't mix the parent class into your class.

--
Barry Margolin, barmar@xxxxxxxxxxxx
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
.



Relevant Pages

  • Re: Include module and class inheritance? which one to choose?
    ... but we can achieve the same thing by inherit a class which will get ... You need to approach this issue in terms of semantics rather than ... functionality which is not dependent on a specific object, ... A Math object wouldn't make much ...
    (comp.lang.ruby)
  • Re: CLOS question
    ... to define a class d that inherits c, and have instances of d behave ... It would seem that D is not really a subclass of C if you don't want ... Each more specific primary method blocks the ... functionality is a capability provided for primary ...
    (comp.lang.lisp)
  • advice on programming style: is multiple inheritance bad?
    ... I got a class A2 that needs to inherit from class A1. ... as well as some other classes implement a same functionality and in ... order to prevent code duplication I'd like to factorize that ... duplicate code into a class SuperA from which then A2 and all other classes ...
    (comp.lang.python)
  • How to Adding Functionality to a Class by metaclass(not by inherit)
    ... How to Adding Functionality to a Class by metaclass(not by inherit) ... #Bar want to achieve Foo's part/all functionality, ... unbound method fmust be called with Foo instance as first argument ...
    (comp.lang.python)
  • How to Adding Functionality to a Class by metaclass(not by inherit)
    ... How to Adding Functionality to a Class by metaclass(not by inherit) ... #Bar want to achieve Foo's part/all functionality, ... unbound method fmust be called with Foo instance as first argument ...
    (comp.lang.python)