Global Virtual Functions

Synonyms

Concept

Global virtual functions (GVF) are procedures/functions in the traditional sense (as found, e. g., in Pascal, Modula-2, and C) which can be overridden or redefined later. In contrast to object-oriented methods or C++ member functions, they do not belong to any type or class, but rather constitute global entities defined in a module.
By redefining a GVF one or more times in one or more modules, a linear chain of definitions (also called branches) is built up at run time, whose precise order is determined by the linear module initialization order as well as the textual order of the definitions inside a module. Invoking a GVF actually means to invoke the last branch of that chain, where each branch is able to call the previous branch on demand.

By applying dynamic type tests or evaluating other conditions on the function's arguments (or even global variables), every branch is able to decide whether it wants to execute its own code or delegate the call to the previous branch. By that means, it is easily possible to simulate standard object-oriented dispatch strategies such as single, multiple, or even predicate dispatch. Furthermore, by executing additional code before and/or after calling the previous branch, the aspect-oriented concept of before/after/around advice is also covered.

Example

An example of global virtual functions is given together with open types.

Publications

[1] C. Heinlein: Vertical, Horizontal, and Behavioural Extensibility of Software Systems. Nr. 2003-06, Ulmer Informatik-Berichte, Fakultät für Informatik, Universität Ulm, July 2003. (PostScript, PDF)
Describes the basic concept of global virtual functions (called dynamic routines there) as well as its application to C++, Oberon, and Java.

[2] C. Heinlein: "Dynamic Class Methods in Java." In: Net.ObjectDays 2003. Tagungsband (Erfurt, Germany, September 2003). tranSIT GmbH, Ilmenau, 2003, ISBN 3-9808628-2-8, 215–229. (PostScript, PDF)
Describes the application to Java (called dynamic class methods) in more detail.

[3] C. Heinlein: Dynamic Class Methods in Java. Nr. 2003-05, Ulmer Informatik-Berichte, Fakultät für Informatik, Universität Ulm, July 2003. (PostScript, PDF)
An extended version of the previous paper.

[4] C. Heinlein: "Virtual Namespace Functions: An Alternative to Virtual Member Functions in C++ and Advice in AspectC++." In: Proc. 2005 ACM Symposium on Applied Computing (SAC) (Santa Fe, New Mexico, March 2005), 1274–1281. (PostScript, PDF)
Describes the application to C++ (called virtual namespace functions) in more detail.

[5] C. Heinlein: "Local Virtual Functions." In: R. Hirschfeld, R. Kowalczyk, A. Polze, M. Weske (eds.): NODe 2005, GSEM 2005 (Erfurt, Germany, September 2005). Lecture Notes in Informatics P-69, Gesellschaft für Informatik e. V., Bonn, 2005, 129–144. (PostScript, PDF)
Describes an extension of global virtual functions called local virtual functions together with non-local jump statements, which can be used, amongst others, to achieve exception handling with the possibility of resumption.

[6] C. Heinlein: "Global and Local Virtual Functions in C++." Journal of Object Technology 4 (10) December 2005, 71–93, http://www.jot.fm/issues/issue_2005_12/article4.
An extended version of the SAC 2005 paper, containing also parts of the NODe 2005 paper and thus providing the most complete picture of global and local virtual functions. Implementation considerations are covered, too.


Impressum    Datenschutz