A virtual class calculus

Reading Martin Oderski's paper Scalable Component Abstractions, I ran across citations to the languages CeasarJ and Gbeta, both realizing a concept called virtual classes. This concept is explained, and a calculus given in the paper A Virtual Class Calculus by Erik Ernst, Klaus Ostermann, and William R. Cook.

Virtual classes are class-valued attributes of objects. Like virtual methods, virtual classes are defined in an object's class and may be redefined within subclasses. They resemble inner classes, which are also defined within a class, but virtual classes are accessed through object instances, not as static components of a class. When used as types, virtual classes depend upon object identity -- each object instance introduces a new family of virtual class types. Virtual classes support large-scale program composition techniques, including higher-order hierarchies and family polymorphism. The original definition of virtual classes in BETA left open the question of static type safety, since some type errors were not caught until runtime. Later the languages Caesar and gbeta have used a more strict static analysis in order to ensure static type safety. However, the existence of a sound, statically typed model for virtual classes has been a long-standing open question. This paper presents a virtual class calculus, VC, that captures the essence of virtual classes in these full-fledged programming languages. The key contributions of the paper are a formalization of the dynamic and static semantics of VC and a proof of the soundness of VC.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Same Source

An excellent follow-up to Oderski's wonderfully approachable "Scalable Component Abstractions" is the considerably more formal "A Nominal Theory of Objects with Dependent Types," aka "the vObj paper," available here.

Follow-up?

Do you mean follow-up in didactical sense, or chronological?
I believe "Scalable Component Abstractions" is newer than "the vObj paper".

And yes, I find the former a really interesting paper (and I keep it on my desk since its publication :) ).

Definitely...

...didactical. "Scalable Component Abstractions" feels to me like the response to a collective "Huh?" reaction to "the vObj paper." :-)

Tribe

On a related note, I found Tribe: More Types for Virtual Classes somewhat more elegant and easier to read than "A Virtual Class Calculus".

Also, I've noticed that most papers on virtual classes seem to mention (in some way or another) extending the calculus to handle object-based inheritance. Since this would provide a nice formal foundation for delegation layers, I was wondering why this hasn't been done yet.

Object-based inheritance and delegation layers

I think the reason is that it is very hard to come up with a sound type-system for object-based inheritance. One can cheat a bit on naming conflicts by requiring some kind of global uniqueness, but there are worse problems related to the right type for "this"/"self" in a dynamically composed chain of objects. It gets even worse if parent objects can be exchanged. A good discussion on many of these issues are in the Ph.D. thesis by Günter Kniesel.

Another reason is that there are not yet any real "killer examples" that can be expressed with delegation layers but not with virtual classes.