Metaclass
In object orientation, a metaclass is the class of a class. It defines procedures for creating instances of the class whose metaclass it is, as well as static methods , i.e. those for whose execution no objects are required.
Not all object-oriented programming languages support the metaclass concept or some only do it to a certain extent.
Languages with metaclasses
The following programming languages support metaclasses:
- Groovy
- python
- Objective-C
- Pearl
- Small talk
- Common Lisp , via CLOS
- Object Pascal (especially in Delphi )
- Logtalk , an object-oriented extension of Prolog
as well as the description languages:
- Resource Description Framework (RDF) and Unified Modeling Language (UML)
Real metaclasses are used, for example, in the Smalltalk or Python programming language . These metaclasses are themselves classes from which subclasses can be derived.
In the Java programming language there is a class Class
that has important properties of a metaclass, for example it can create objects of other classes, but no more specific metaclasses can be derived from it.