Metaobject


In computer science, a metaobject is an object that manipulates, creates, describes, or implements objects (including itself). The object that the metaobject pertains to is called the base object. Some information that a metaobject might define includes the base object's type, interface, class, methods, attributes, parse tree, etc. Metaobjects are examples of the computer science concept of reflection, where a system has access (usually at run time) to its own internal structure. Reflection enables a system to essentially rewrite itself on the fly, to alter its own implementation as it executes.[1]




Contents





  • 1 Metaobject protocol

    • 1.1 Runtime and compile time


    • 1.2 Usage



  • 2 See also


  • 3 References


  • 4 External links




Metaobject protocol


A metaobject protocol (MOP) provides the vocabulary (protocol) to access and manipulate the structure and behaviour of systems of objects. Typical functions of a metaobject protocol include:[2]


  • Create or delete a new class

  • Create a new property or method

  • Cause a class to inherit from a different class ("change the class structure")

  • Generate or change the code defining the methods of a class

Metaobject protocol is contrary to the "closed" aspect of Bertrand Meyer's open/closed principle, which holds that software object systems should be open for extension but closed for modification. Metaobject protocol, by contrast, transparently exposes the internal composition of objects and the entire object system in terms of the system itself. A metaobject protocol is not merely an interface to an "underlying" implementation; rather, through metaobject protocol the object system is recursively implemented in terms of a meta-object system, which itself is theoretically implemented in terms of a meta-metaobject system, and so on until an arbitrary base case (a consistent state of the object system) is determined, with the protocol as such being the recursive functional relationship between these implementation levels.


Implementing object systems in such a way opens the possibility for radical discretionary redesign, providing deep flexibility but introducing possibly complex or difficult-to-understand metastability issues (for instance, the object system must not destructively update its own metaobject protocol - its internal self-representation - but the potential destructiveness of some updates is non-trivial to predict and may be hard to reason about), depending on the recursive depth to which the desired modifications are propagated.[3] For this reason, metaobject protocol, when present in a language, is usually used sparingly and for specialised purposes such as software that transforms other software or itself in sophisticated ways, for example in reverse engineering.[4]



Runtime and compile time


When compilation is not available at run-time there are additional complications for the implementation of metaobject protocol. For example, it is possible to change the type hierarchy with such a protocol but doing so may cause problems for code compiled with an alternative class model definition. Some environments have found innovative solutions for this, e.g., by handling metaobject issues at compile time. A good example of this is OpenC++.[5]


It is noteworthy that the Semantic Web object-oriented model is more dynamic than most standard object systems, and is consistent with runtime metaobject protocols. For example, in the Semantic Web model classes are expected to change their relations to each other and there is a special inference engine known as a classifier that can validate and analyze evolving class models.[6]



Usage


The first metaobject protocol was in the Smalltalk object-oriented programming language developed at Xerox PARC. The Common Lisp Object System (CLOS) came later and was influenced by the Smalltalk protocol as well as by Brian C. Smith's original studies on 3-Lisp as an infinite tower of compilers.[7] The CLOS model, unlike the Smalltalk model, allows a class to have more than one superclass; this raises additional complexity in issues such as resolving the lineage of the class hierarchy on some object instance. CLOS also allows for dynamic multimethod dispatch, which is handled via generic functions rather than message passing like in Smalltalk's single dispatch.[8] The most influential book describing the semantics and implementation of the metaobject protocol in Common Lisp is The Art of the Metaobject Protocol by Gregor Kiczales et al.[9]


Metaobject protocols are also extensively used in software engineering applications. In virtually all commercial CASE, re-engineering, and Integrated Development Environments there is some form of metaobject protocol to represent and manipulate the design artifacts.[10][11][12]


A metaobject protocol is one way to implement aspect-oriented programming. Many of the early founders of MOPs, including Gregor Kiczales, have since moved on to be the primary advocates for aspect-oriented programming. Kiczales et al. of PARC were hired to design AspectJ for Java, a language which does not possess a native metaobject protocol.



See also


  • Kind (type theory)

  • Metaclass

  • Javassist

  • Joose JavaScript meta object system

  • Moose Perl meta object system

  • OpenC++

  • OpenJava


  • Unified Modeling Language: UML

  • Groovy


References




  1. ^ Smith, Brian C (1982-01-01). "Procedural Reflection In Programming Languages". MIT Technical Report (MIT-LCS–TR-272). Retrieved 16 December 2013..mw-parser-output cite.citationfont-style:inherit.mw-parser-output qquotes:"""""""'""'".mw-parser-output code.cs1-codecolor:inherit;background:inherit;border:inherit;padding:inherit.mw-parser-output .cs1-lock-free abackground:url("//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png")no-repeat;background-position:right .1em center.mw-parser-output .cs1-lock-limited a,.mw-parser-output .cs1-lock-registration abackground:url("//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png")no-repeat;background-position:right .1em center.mw-parser-output .cs1-lock-subscription abackground:url("//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png")no-repeat;background-position:right .1em center.mw-parser-output .cs1-subscription,.mw-parser-output .cs1-registrationcolor:#555.mw-parser-output .cs1-subscription span,.mw-parser-output .cs1-registration spanborder-bottom:1px dotted;cursor:help.mw-parser-output .cs1-hidden-errordisplay:none;font-size:100%.mw-parser-output .cs1-visible-errorfont-size:100%.mw-parser-output .cs1-subscription,.mw-parser-output .cs1-registration,.mw-parser-output .cs1-formatfont-size:95%.mw-parser-output .cs1-kern-left,.mw-parser-output .cs1-kern-wl-leftpadding-left:0.2em.mw-parser-output .cs1-kern-right,.mw-parser-output .cs1-kern-wl-rightpadding-right:0.2em


  2. ^ Foote, Brian; Ralph Johnson (1–6 October 1989). "Reflective Facilities in Smalltalk-80". OOPSLA '89. Retrieved 16 December 2013.


  3. ^ The Art of the Metaobject Protocol, Appendix C — Living with Circularity


  4. ^ Favre, Lilliana; Liliana Martinez; Claudia Pereira (2009). MDA-Based Reverse Engineering of Object Oriented Code. Springer. ISBN 978-3-642-01861-9.


  5. ^ Chiba, Shigeru (1995). "A Metaobject Protocol for C++". OOPSLA '95. Retrieved 27 December 2013.


  6. ^ Knublauch, Holger; Oberle, Daniel; Tetlow, Phil; Wallace, Evan (2006-03-09). "A Semantic Web Primer for Object-Oriented Software Developers". W3C. Retrieved 2008-07-30.


  7. ^ Daniel P. Friedman; Mitchell Wand (1988). "The mystery of the tower revealed: A non-reflective description of the reflective tower". Retrieved 2017-01-16.


  8. ^ "Integrating Object-Oriented and Functional Programming" (PDF). Retrieved 7 July 2016.


  9. ^ Kiczales, Gregor; Jim des Rivieres; Daniel G. Bobrow (July 30, 1991). The Art of the Metaobject Protocol. The MIT Press. ISBN 978-0262610742.


  10. ^ Johnson, Lewis; David R. Harris; Kevin M. Benner; Martin S. Feather (October 1992). "Aries: The Requirements/Specification Facet for KBSA". Rome Laboratory Final Technical Report. RL-TR-92-248.


  11. ^ "The Origin of Refine" (PDF). www.metaware.fr. Metaware White Paper. Archived from the original (PDF) on 7 January 2014. Retrieved 6 January 2014.


  12. ^ "OMG's MetaObject Facility". omg.org. Object Management Group. Retrieved 7 January 2014.




External links


  • The Guile MOP specification (GOOPS, based on Tiny CLOS)

  • Metaobjects and the Metaobject Protocol


  • Common Lisp Object System Metaobject Protocol (contains two chapters from The Art of the Metaobject Protocol)

  • Python 3 Metaprogramming








Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?