erics@eleazar.dartmouth.edu (Eric Schlegel) (11/14/89)
In article <5162@internal.Apple.COM> lsr@Apple.COM (Larry Rosenstein) writes: >MPW C++ can support several kinds of object representation and >dispatching. > >(1) Standard C++ dispatching, which supports multiple inheritance, > pointer-based objects, etc. >(2) Object Pascal style dispatching, which includes handle-based objects. >(3) You can use handle-based objects with C++ dispatching. >(4) CFront 1.2 style dispatching, which uses pointer-based objects The C++ manual notes that multiple inheritance is NOT available for classes derived from HandleObject. Does anyone know why? Larry, are there any plans to correct this in the future? Yes, I know that just about anything you can do with MI, you can do with single. Still, it would be nice to have together with HandleObjects. eric eric.schlegel@dartmouth.edu
siegel@endor.harvard.edu (Rich Siegel) (11/14/89)
In article <16875@dartvax.Dartmouth.EDU> erics@eleazar.dartmouth.edu (Eric Schlegel) writes: > >The C++ manual notes that multiple inheritance is NOT available for classes >derived from HandleObject. Does anyone know why? Larry, are there any plans >to correct this in the future? Without getting into an insanely complicated (and somewhat irrelevant) description of object dispatches... The dispatch mechanism used for supporting multiple inheritance is incompatible with the relocatable-block structure of the Mac memory manager. R. ~~~~~~~~~~~~~~~ Rich Siegel Staff Software Developer Symantec Corporation, Language Products Group Internet: siegel@endor.harvard.edu UUCP: ..harvard!endor!siegel "There is no personal problem which cannot be solved by sufficient application of high explosives." ~~~~~~~~~~~~~~~
erics@eleazar.dartmouth.edu (Eric Schlegel) (11/14/89)
In article <3158@husc6.harvard.edu> siegel@endor.UUCP (Rich Siegel) writes: > Without getting into an insanely complicated (and somewhat irrelevant) >description of object dispatches... The dispatch mechanism used for >supporting multiple inheritance is incompatible with the relocatable-block >structure of the Mac memory manager. I'm perfectly happy to accept that, but I am curious.. is this is _permanent_ incompatibility, or might it be fixed someday? eric eric.schlegel@dartmouth.edu
lsr@Apple.COM (Larry Rosenstein) (11/15/89)
In article <16898@dartvax.Dartmouth.EDU> erics@eleazar.dartmouth.edu (Eric Schlegel) writes: > I'm perfectly happy to accept that, but I am curious.. is this is _permanent_ > incompatibility, or might it be fixed someday? Now that Rich has reminded me of why HandleObjects don't support multiple inheritance, I can answer more intelligently. (Thanks, Rich.) It is unlikely that this will change. MPW C++ uses the standard runtime implementation from AT&T's CFront product. I don't think there's any motivation for AT&T to change the implementation; I don't know whether Apple would want to make such an extensive modification to CFront. There's a paper (by Bjarne Stroustrup, I think) on the implementation. The problem for handle objects is that the C++ runtime implementation must move the pointer to the object before it calls a method. Normally you allocate and object on the heap and return pointer to it. Then you pass that pointer as a hidden parameter to each method call. With multiple inheritance, calling a method involves adding an offset to that pointer and passing the result as the hidden parameter. With a handle-based object, there's no way to pass a handle into the middle of the object. The only alternative I can think of is to use doubly-indirect pointers to objects (e.g., TMyObject **anObj). You can overload operator new with something like: (NOTE: I haven't tried this to see if it works, so be careful.) typedef enum {NewHandle} OperatorNewFlag; void* operator new(size_t objSize, OperatorNewFlag) { return (void*)NewHandle(objSize); } Then you would use it like: TMyObject **anObj = (TMyObject**) new(NewHandle) TMyObject(...); This is using the feature of C++ that lets you pass added parameters to operator new. In this case, we only care about the type of the parameter, and not its actual value. The statement above will call the overloaded operator new and allocate a handle. You have to remember this and coerce the result to the proper type. Once you have allocated the object in this way, then you can use it as a regular C++ object (e.g., *anObj -> Method(...)). You have to realize that this is using a dereferenced handle with all the cautions that apply in that case. Larry Rosenstein, Apple Computer, Inc. Object Specialist Internet: lsr@Apple.com UUCP: {nsc, sun}!apple!lsr AppleLink: Rosenstein1
ech@cbnewsk.ATT.COM (ned.horvath) (11/16/89)
In article <3158@husc6.harvard.edu> siegel@endor.UUCP (Rich Siegel) writes: > Without getting into an insanely complicated (and somewhat irrelevant) > description of object dispatches... The dispatch mechanism used for > supporting multiple inheritance is incompatible with the relocatable-block > structure of the Mac memory manager. From article <16898@dartvax.Dartmouth.EDU>, by erics@eleazar.dartmouth.edu (Eric Schlegel): > I'm perfectly happy to accept that, but I am curious.. is this is _permanent_ > incompatibility, or might it be fixed someday? Rich overstates the case a bit: the multiple-inheritance scheme CURRENTLY USED by MPW C++ doesn't support handle-based objects. There's no good reason that this MUST be the case. Start complaining now... =Ned Horvath=