S
Steven T. Hatton
I've had an idea kicking around in my head regarding how to create a library
of classes (templates?) that provide the same kind of functionality as do
Java classes which all derive from the UBC Object. There is no UBC in C++,
nor will there ever be one (well, there actually /is/ a UBC in C++, but it
is a pure abstraction). One feature of user defined Java classes is that
they all have a member derived from the java.lang.Class object. The Class
member object is part of what provides introspection. I haven't looked at
this in a couple years, so the details are a bit hazy for me. Another
aspect of Java classes is that all their member functions (AKA methods) are
actually objects (or at least can be represented as objects). A Method
object holds information such as the identifier and an array of Class
objects representing the parameter list. You can query a Java object at
runtime to determine its interface. You can also get its superclass (AKA
baseclass), etc.
C++ has objects that act like functions. Could a C++ class be created with
public function objects derived from a class called Function, and providing
the same functionality as the Java Method objects?
I don't know exactly how useful this would be, but it seems worth exploring
in view of the fact that both Java and C# have something like this as a
builtin language feature. One place where this is useful is actually at
design time. Classes are instantiated by the IDE, and queried for their
contents. For the functionality gained I don't believe you actually need
to use this approach. You could simply explore the class definition and
instantiate an IDE object representing the C++ class. AAMOF, KDevelop does
this to some extent.
of classes (templates?) that provide the same kind of functionality as do
Java classes which all derive from the UBC Object. There is no UBC in C++,
nor will there ever be one (well, there actually /is/ a UBC in C++, but it
is a pure abstraction). One feature of user defined Java classes is that
they all have a member derived from the java.lang.Class object. The Class
member object is part of what provides introspection. I haven't looked at
this in a couple years, so the details are a bit hazy for me. Another
aspect of Java classes is that all their member functions (AKA methods) are
actually objects (or at least can be represented as objects). A Method
object holds information such as the identifier and an array of Class
objects representing the parameter list. You can query a Java object at
runtime to determine its interface. You can also get its superclass (AKA
baseclass), etc.
C++ has objects that act like functions. Could a C++ class be created with
public function objects derived from a class called Function, and providing
the same functionality as the Java Method objects?
I don't know exactly how useful this would be, but it seems worth exploring
in view of the fact that both Java and C# have something like this as a
builtin language feature. One place where this is useful is actually at
design time. Classes are instantiated by the IDE, and queried for their
contents. For the functionality gained I don't believe you actually need
to use this approach. You could simply explore the class definition and
instantiate an IDE object representing the C++ class. AAMOF, KDevelop does
this to some extent.