Path: utzoo!utgpu!water!watmath!clyde!att!pacbell!ames!pasteur!helios.ee.lbl.gov!nosc!ucsd!ucbvax!agate!garnet.berkeley.edu!elcond From: elcond@garnet.berkeley.edu (Gregory Dow) Newsgroups: comp.sys.mac.programmer Subject: Inheritance in The Crunched Shell Keywords: Object-oriented programming Message-ID: <12405@agate.BERKELEY.EDU> Date: 22 Jul 88 07:09:09 GMT References: <2328@pt.cs.cmu.edu> <12362@agate.BERKELEY.EDU> <60865@sun.uucp> Sender: usenet@agate.BERKELEY.EDU Organization: University of California, Berkeley Lines: 33 In article <60865@sun.uucp> landman@sun.UUCP (Howard A. Landman) writes: [description of how single inheritance is achieved through nested #include's] >Gee - this sounds like you can get multiple inheritance just by nesting >2 or more include files. So why "single only"? (Assuming no conflicts.) >Is it because you need to know which SuperClass to pass a message to if the >local Class can't handle it, so the dispatcher would get more complicated? > 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. Similarly for a Class B which is also descended from the root class. If a Class X has both A and B as superclasses, it will not know how to handle the message number 4. Message 4 may be a FOO message to Class A, and a BAR message to Class B, but the Class X has no way of knowing which one it is. The C preprocessor converts both FOO and BAR to 4. 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. Gregory Dow ARPA: elcond@garnet.berkeley.edu Chemical Engineering Dept. UUCP: {uwvax, decvax, ihnp4, ...}!ucbvax University of California !elcond%garnet.berkeley.edu Berkeley, CA 94720 BITNET: POLYDOW@UCBCMSA