home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c++:11333 comp.std.c++:915
- Newsgroups: comp.lang.c++,comp.std.c++
- Path: sparky!uunet!usc!sdd.hp.com!mips!mips!rtech!ingres!bobm
- From: bobm@Ingres.COM (Bob McQueer)
- Subject: Re: Language extensions for run-time type identification
- Message-ID: <1992Jul22.173019.6534@pony.Ingres.COM>
- References: <14ft2uINNjh4@agate.berkeley.edu>
- Date: 22 Jul 92 17:30:19 GMT
- Lines: 35
-
- In <14ft2uINNjh4@agate.berkeley.edu>,
- dated 21 Jul 92 02:34:06 GMT,
- jbuck@forney.berkeley.edu (Joe Buck) writes:
-
- > In most implementations of classes with virtual functions, each object
- > already has, in effect, a type-ID: the pointer to the virtual function
- > table. This is a natural hook on which to hang run time type checking.
-
- I think Mr. Buck has hit the nail on the head here. I've been meaning to ask
- about this myself, and was happy to see this discussion thread start. The
- virtual function table exists as a 1-per-class structure, and is the natural
- place to insert other runtime class information without replicating anything.
- The reasonable overhead on each object instantiation would be 1 pointer to
- the virtual function table, which we might want to start calling a class
- descriptor, or something like that.
-
- I think we have to recognize that C++ is not a purist's OO language - it
- is a way of adding OO functionality to an existing language. Its strength
- lies in being able to use an OO paradigm, while still retaining the
- efficiency of C, and having "escape hatches". Insisting that only certain
- classes can have runtime descriptors seems reasonable, given this intent.
-
- What I was going to ask about was actually support for an "isa" operation,
- which requires some type of runtime definition. Yes, this type of thing can
- be abused, but it is definitely useful. It should NOT be used as a substitute
- for proper subclassing and definition of virtual functions, but I think it
- is needed.
-
- Another aspect - if we have the ability to get at class descriptors, can there
- be an extension which allows them to be used with the "new" operator to
- parameterize the class of object being allocated. I think that as "service"
- classes begin to be provided, it might be handy. Think in terms of C++
- application generators which generate the code to manipulate certain classes of
- objects, which may be customized by allowing the user to subclass the basic
- types.
-