Metaobject
Encyclopedia
In computer science
Computer science
Computer science or computing science is the study of the theoretical foundations of information and computation and of practical techniques for their implementation and application in computer systems...

, a metaobject or meta-object is any entity that manipulates, creates, describes, or implements other object
Object (computer science)
In computer science, an object is any entity that can be manipulated by the commands of a programming language, such as a value, variable, function, or data structure...

s. The object that the metaobject is about is called the base object. Some information that a metaobject might store is the base object's type
Type system
A type system associates a type with each computed value. By examining the flow of these values, a type system attempts to ensure or prove that no type errors can occur...

, interface
Interface (computer science)
In the field of computer science, an interface is a tool and concept that refers to a point of interaction between components, and is applicable at the level of both hardware and software...

, class
Class (computer science)
In object-oriented programming, a class is a construct that is used as a blueprint to create instances of itself – referred to as class instances, class objects, instance objects or simply objects. A class defines constituent members which enable these class instances to have state and behavior...

, method
Method (computer science)
In object-oriented programming, a method is a subroutine associated with a class. Methods define the behavior to be exhibited by instances of the associated class at program run time...

s, attributes
Attribute (computing)
In computing, an attribute is a specification that defines a property of an object, element, or file. It may also refer to or set the specific value for a given instance of such....

, variables
Variable (programming)
In computer programming, a variable is a symbolic name given to some known or unknown quantity or information, for the purpose of allowing the name to be used independently of the information it represents...

, functions
Function (mathematics)
In mathematics, a function associates one quantity, the argument of the function, also known as the input, with another quantity, the value of the function, also known as the output. A function assigns exactly one output to each input. The argument and the value may be real numbers, but they can...

, control structures
Control flow
In computer science, control flow refers to the order in which the individual statements, instructions, or function calls of an imperative or a declarative program are executed or evaluated....

, etc.

Metaobject protocol

A metaobject protocol (MOP) is an interpreter
Interpreter (computing)
In computer science, an interpreter normally means a computer program that executes, i.e. performs, instructions written in a programming language...

 of the semantics
Semantics
Semantics is the study of meaning. It focuses on the relation between signifiers, such as words, phrases, signs and symbols, and what they stand for, their denotata....

 of a program that is open and extensible. Therefore, a MOP determines what a program means and what its behavior is, and it is extensible in that a programmer (or metaprogrammer
Metaprogramming
Metaprogramming is the writing of computer programs that write or manipulate other programs as their data, or that do part of the work at compile time that would otherwise be done at runtime...

) can alter program behavior by extending parts of the MOP. The MOP exposes some or all internal structure of the interpreter to the programmer. The MOP may manifest as a set of classes and methods that allow a program to inspect the state
State (computer science)
In computer science and automata theory, a state is a unique configuration of information in a program or machine. It is a concept that occasionally extends into some forms of systems programming such as lexers and parsers....

 of the supporting system and alter its behaviour. MOPs are implemented as object-oriented
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...

 programs where all objects are metaobjects.

Runtime and compile time

MOPs may be run-time or compile-time. The metaobjects of runtime MOPs exist while a program is running, or executing. Instead, the metaobjects of compile-time MOPs exist only while a program is compiled. They may alter or extend the compiling process, but do not exist when the program is running.

One of the best-known runtime MOPs is the one described in the book The Art of the Metaobject Protocol
The Art of the Metaobject Protocol
The Art of the Metaobject Protocol is a 1991 book by Gregor Kiczales, Jim des Rivieres, and Daniel G. Bobrow on metaobject protocol...

(often referred to as AMOP); it applies to the Common Lisp
Common Lisp
Common Lisp, commonly abbreviated CL, is a dialect of the Lisp programming language, published in ANSI standard document ANSI INCITS 226-1994 , . From the ANSI Common Lisp standard the Common Lisp HyperSpec has been derived for use with web browsers...

 Object System (CLOS) and allows the mechanisms of inheritance
Inheritance (computer science)
In object-oriented programming , inheritance is a way to reuse code of existing objects, establish a subtype from an existing object, or both, depending upon programming language support...

, method dispatching, class instantiation and so on to be manipulated. At Xerox PARC
Xerox PARC
PARC , formerly Xerox PARC, is a research and co-development company in Palo Alto, California, with a distinguished reputation for its contributions to information technology and hardware systems....

, one of the authors of AMOP, Gregor Kiczales
Gregor Kiczales
Gregor Kiczales is a professor of computer science at the University of British Columbia in Canada. His best known work is on Aspect-oriented programming and the AspectJ extension for Java at Xerox PARC. He has also contributed to the design of the Common Lisp Object System, and is the author of...

, developed a small but powerful MOP-based runtime object system in Scheme called TinyCLOS. which has been ported to many Scheme implementations.

A good example of a compile-time MOP is OpenC++.

Usage

One example use of a MOP is to alter the implementation of multiple inheritance
Multiple inheritance
Multiple inheritance is a feature of some object-oriented computer programming languages in which a class can inherit behaviors and features from more than one superclass....

. A recurring issue is how to resolve conflicting slots and methods of the superclasses. Typically, language designers select one solution, and language users must live with it. Instead, a metaobject protocol makes it possible to change the rules of inheritance and choose a different solution for individual classes.

A metaobject protocol is one way to implement aspect-oriented programming
Aspect-oriented programming
In computing, aspect-oriented programming is a programming paradigm which aims to increase modularity by allowing the separation of cross-cutting concerns...

 languages. Many of the early founders of MOPs, including Gregor Kiczales
Gregor Kiczales
Gregor Kiczales is a professor of computer science at the University of British Columbia in Canada. His best known work is on Aspect-oriented programming and the AspectJ extension for Java at Xerox PARC. He has also contributed to the design of the Common Lisp Object System, and is the author of...

 have since moved on to be the primary advocates for aspect-oriented programming.

See also

  • CLOS
  • EuLisp
    EuLisp
    EuLisp is a statically and dynamically scoped Lisp dialect developed by a loose formation of industrial and academic Lisp users and developers from around Europe. The standardizers intended to create a new Lisp "less encumbered by the past" , and not so minimalistic as Scheme...

  • Javassist
    Javassist
    Javassist is a Java library providing a means to manipulate the Java bytecode of an application. In this sense Javassist provides the support for structural reflection, i.e...

  • Joose JavaScript meta object system
    Joose (framework)
    Joose is an open-source self-hosting meta object system for JavaScript with support for classes, inheritance, mixins, traits and aspect oriented programming....

  • Moose Perl meta object system
    Moose (Perl)
    Moose is an extension of the Perl 5 object system. It brings modern object-oriented language features to Perl 5, making object-oriented programming more consistent and less tedious.-Features:...

  • OpenC++
  • OpenJava
    OpenJava
    OpenJava is a programming tool that parses and analyzes Java source code. It uses a metaobject protocol to provide services for language extensions. Michiaki Tatsubori was the lead developer of OpenJava...

  • Unified Modeling Language
    Unified Modeling Language
    Unified Modeling Language is a standardized general-purpose modeling language in the field of object-oriented software engineering. The standard is managed, and was created, by the Object Management Group...

    : UML
  • Groovy
  • Ruby
    Ruby (programming language)
    Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was first developed and designed by Yukihiro "Matz" Matsumoto...

  • Python
    Python (programming language)
    Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...

  • Perl 6
    Perl 6
    Perl 6 is a major revision to the Perl programming language. It is still in development, as a specification from which several interpreter and compiler implementations are being written. It is introducing elements of many modern and historical languages. Perl 6 is intended to have many...


External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK