Previous    Next


Some object-oriented languages do not use the notion of class at all. In such a language, each object implements whatever methods and has whatever data fields it wants. Type-checking for such languages is usually dynamic (done at run time) instead of static (done at compile time). Many objects are created by cloning: copying an existing object (or template object) and then modifying some of the fields. Thus, even in a classless language there will be groups ("pseudo-classes") of similar objects that can share descriptors. When b is created by cloning a, it can share a descriptor with a. Only if a new field is added or a method field is updated (overridden) does b require a new descriptor. The techniques used in compiling classless languages are similar to those for class-based languages with multiple inheritance and dynamic linking: Pseudo-class descriptors contain hash tables that yield field offsets and method instances.

The same kinds of global program analysis and optimization that are used for class-based languages - finding which method instance will be called from a (dynamic) method call site - are just as useful for classless languages.

JaVaScreenshot Previous    Next