Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!pasteur!ucbvax!decwrl!nsc!voder!apple!lsr From: lsr@Apple.COM (Larry Rosenstein) Newsgroups: comp.sys.mac.programmer Subject: Re: Inheritance in The Crunched Shell Keywords: Object-oriented programming Message-ID: <14934@apple.Apple.COM> Date: 29 Jul 88 16:09:21 GMT References: <2328@pt.cs.cmu.edu> <12362@agate.BERKELEY.EDU> <60865@sun.uucp> <12405@agate.BERKELEY.EDU> Reply-To: lsr@apple.apple.com.UUCP (Larry Rosenstein) Organization: Advanced Technology Group, Apple Computer Lines: 39 In article <12405@agate.BERKELEY.EDU> elcond@garnet.berkeley.edu (Gregory Dow) writes: > >The SuperClass ordering is one problem (depth-first or breadth-first search), >the other is more mundane. Message names are implemented as an enumerated >type, which C automatically converts to integer values. The root object >class has 3 messages, which get numbered as 0, 1, and 2. If Class A, >a child of the root class, has 4 messages, they get numbered 3, 4, 5, and 6. This is the dispatching scheme we used in the very first implementation of Object Pascal (nee Clascal), and it is used in the single-inheritance C++. It has the virtue of being very fast, because it pre-computes the address of the code for each message understood by a class. The time to call a method is constant. When you make a subclass, the subclass' table starts out as a copy of the superclass' table. You add any new methods onto the end, and replace any entries that are overridden. So even if you override 1 method, you still have to copy the entire superclass table. The current Object Pascal dispatcher minimizes the space by only putting the methods a class actually implements into the table. For info on this, see the December 1986 MacTutor. >Can anyone suggest an alternative? I'd love it if I could easily implement >the "set" data structure from Pascal in C. Then I could just take the >union of the messages of the superclasses of a class. I'd really like >to find a clean solution to this problem, because standard C++ doesn't >support multiple inheritance either. I think Stroustrup had a paper in the C++ Workshop Proceedings on multiple inheritance in C++. AT&T also had the paper in its booth at the last OOPSLA. It retains the constant-time method call feature of C++, with only a little increase in space and complexity. Larry Rosenstein, Object Specialist Apple Computer, Inc. 20525 Mariani Ave, MS 46-B Cupertino, CA 95014 AppleLink:Rosenstein1 domain:lsr@Apple.COM UUCP:{sun,voder,nsc,decwrl}!apple!lsr