home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / object / 3516 < prev    next >
Encoding:
Internet Message Format  |  1992-09-11  |  2.0 KB

  1. Path: sparky!uunet!sun-barr!cs.utexas.edu!usc!sdd.hp.com!think.com!barmar
  2. From: barmar@think.com (Barry Margolin)
  3. Newsgroups: comp.object
  4. Subject: Re: Object-Oriented Methodologies - Class Specifications
  5. Date: 12 Sep 1992 03:20:37 GMT
  6. Organization: Thinking Machines Corporation, Cambridge MA, USA
  7. Lines: 30
  8. Message-ID: <18rnm5INNisq@early-bird.think.com>
  9. References: <715276480.1.p00058@mail.psi.net> <1992Sep2.135247.11696@bcrka451.bnr.ca> <5740@osc.COM>
  10. NNTP-Posting-Host: telecaster.think.com
  11. Keywords: signature
  12.  
  13. In article <5740@osc.COM> Joe Keane <jgk@osc.com> writes:
  14. >Suppose that there are well-known classes A and B, and a method M which
  15. >operates on instances of both.  Initially there is an implementation for
  16. >M(A,B) and we want to see how people can override this implementation.  Now
  17. >suppose that person X makes a class AX which is a subclass of A.  Then he can
  18. >write a new implementation for the combination M(AX,B).  Similarly, person Y
  19. >makes a class BY which is a subclass of B, and also writes an implementation
  20. >for the combination M(A,BY).
  21. >
  22. >So what happens when the method M is called with the combination M(AX,BY)?
  23.  
  24. Yes, this can be a problem.  The solution CLOS takes is arbitrary, but
  25. pretty simple: there's a precedence order to the arguments (left-to-right
  26. by default, but the definition of a generic function can override this).
  27. So, in the default case, M(AX,BY) would invoke M(AX,B); if it calls
  28. CALL-NEXT-METHOD this will invoke M(A,BY), and if this calls
  29. CALL-NEXT-METHOD it will invoke M(A,B).
  30.  
  31. Things are simplified if the classes are defined in mixin style, using
  32. :BEFORE and :AFTER methods for the X and Y mixin classes, rather than
  33. shadowing the M method totally.  In that case, the standard method
  34. combination facility will arrange for all the methods to run automatically.
  35.  
  36. The metaobject protocol can be used to define other conflict resolution
  37. schemes, including signalling an error due to the ambiguity.
  38. -- 
  39. Barry Margolin
  40. System Manager, Thinking Machines Corp.
  41.  
  42. barmar@think.com          {uunet,harvard}!think!barmar
  43.