| ClassInformation[class, Symbol] returns a list of member names of class wrapped into HoldPattern. A field is directly taken as member symbol, while it is a function name for a function. |
| ClassInformation[class, Pattern] returns a list of members of class wrapped into HoldPattern. Modifiers, like Static, Abstract, Public, Protected, and Private, and attributes are stripped off and patterns may have been renamed. If class has attributes ReadProtected and Locked, the information is encoded. |
| ClassInformation[class, Using, slot] returns a short usage message for the given slot'th member of class. Such messages are a "string" attribute of the class member. One or two exclamation marks ("!" and "!!") after the string allow to separate the short and long forms of the help on this member. |
| ClassInformation[class, Using, slot, LongForm] accesses a longer description. |
| ClassInformation[class, pattern] returns the defining class and the slot position of pattern within class. If applied to a method name, the slots of a set of overloaded methods are included as alternatives. For methods, the method call, possibly with evaluated arguments, is wrapped into Hold and also returned. |
| ClassInformation[object, ...] returns the same information for the given object. |
This loads the package.
We start with the definition of a base class and a child class. We use Override to emphasize that functionality of a parent class is changed.
We first retrieve the symbols defining class members. A child class lists its own symbols and the symbols of its parent. The list of the base class is not affected. The automatically generated default constructor is also found in the symbols' list. Next, we list the patterns found in base, the automatically generated default constructor included. Because names of patterns do not matter, the functionality of the patterns is identical to the given definition. The condition is specially processed in order to allow access to class members. We now use ClassInformation to locate a method and take care of argument evaluation. The artificially introduced Print statement shows that methods with hold attributes do not get their arguments evaluated. This does not have an effect for the global symbol held.
|