Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

// request.cf · coarse context

A page that knows where it met you.

Only coarse request metadata is shown. This demo does not display or persist visitor IP addresses.

Country
US
Cloudflare location
CMH
Connection
HTTP/2
Language
Not provided

Ray ID: a222752b585d0555

Jump to content

Mirror (programming)

From Wikipedia, the free encyclopedia

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::getClass() to get a java.lang.Class<?>).

Mirrors adhere to the qualities of encapsulation, stratification and ontological correspondence.[1]

Benefits

[edit]

Decoupling the reflection mechanism from the objects themselves allows for a few benefits:

  • The object's interface is not polluted, so there is no danger of breaking reflection by overriding a reflective method.
  • There can be different mirror systems.
  • The mirror system can be removed entirely (potentially allowing for optimizations).
  • A mirror system can operate on remote code, since it is not coupled with a particular machine.

Languages that use mirrors

[edit]
  • C++, via the ^^ operator and the returned type std::meta::info.[2]
  • Dart, via its reflect() function.
  • Inko,[3] via its std::mirror module.
  • Rubinius (Ruby implementation), via its Rubinius::Mirror.reflect() method.[4]
  • Scala[5]
  • Swift, via its Swift.Mirror class and the reflect() function.

See also

[edit]

References

[edit]
  1. Gilad Bracha and David Ungar, "Meta-level Facilities of Object-Oriented Programming languages"
  2. cppreference.com. "std::meta::info". cppreference.com. Retrieved 19 May 2026.
  3. "Frequently Asked Questions".
  4. "Rubinius/Mirror.rb at master · rubinius/Rubinius".
  5. "Environment, Universes, and Mirrors".