In computer programming, a mirror is a reflection mechanism that is completely decoupled from the object whose structure is being introspected. This is as opposed to traditional reflection, for example in Java, where one introspects an object using methods from the object itself (e.g. java.lang.Object's getClass() method to get a java.lang.Class<?>).
Mirrors adhere to the qualities of encapsulation, stratification and ontological correspondence.
Decoupling the reflection mechanism from the objects themselves allows for a few benefits:
^^ operator and the returned fundamental type std::meta::info.typeof operator (see typeof) and its returned System.Type instance, representing a type metadata.reflect() function.std::mirror module.X.class which returns a java.lang.Class instance representing a type metadata; note that unlike java.lang.Object's getClass() method, which returns a wildcarded java.lang.Class<?>, X.class is a java.lang.Class<X>.X::class which returns a kotlin.reflect.KClass<X>. Note that in Kotlin, a Java class metadata (java.lang.Class<X>) can be obtained with X::class.java.Rubinius::Mirror.reflect() method.std::mem::type_info::Type and std::any::TypeId.Swift.Mirror class and the reflect() function.