What is the nomenclature for the relationship of a class to its associated metaclass?

Viewed 65

What do we call the relationship of a class towards its associated metaclass?

I'd like to fill the blank in the following two lines:

  • Class A is the metaclass of class B.
  • Class B is the ________ of class A.

In the documentation of the class, I am documenting a metaclass I am currently writing. I find my self typing "the class associated to this metaclass" very often in the python docstrings. Is there a single word which I can use to denote this kind of relationship in a more concise manner?

Condensed example in which I'd like to use a more concise nomenclature:

def __init__(mcl, what, bases=None, dict=None):
  """
  Raises an exception if >> the class associated to this metaclass << 
  contains a valid set of configuration decorators.
  ...
  """
2 Answers

The term "metaclass" itself already captures much of the relationship you are looking. A metaclass isn't really a special thing; it's just another type. The "magic" is that instances of this type also happen to be types. (What is a type? It's just a class which provides methods for objects.)

If anything, classes are the special things. You could imagine that metametaclasses exist: types whose instances are metaclasses, whose instances are classes. You could build up an infinite hierarchy of such metameta...classes. (In practice, this doesn't exist in Python. The root metaclass type has itself as its own metaclass, not some other higher-order metametaclass.) A class, then, is unique as the only sort of type whose instances cannot also serve as types.

The relationship you are looking for is just "class B is an instance of (meta)class A".

(Nothing I say here should be taken as a contradiction of jsbueno's answer; I think it's just a different perspective.)

There is no official nomenclature for that. The only way to go is the full formal way: "the class B for which A is the metaclass" or equivalent.

Technically one could just say that "class B" is an "instance of "class A" - but no other context given it would be very hard for anyone to figure out you are talking about class-metaclass relationship.

For the specific case you mention, though, it would work, I think - you could replace ">> the class associated to this metaclass << " for ">> the class which is an instance of this metaclass << "

Related