05.08.2014 Views

here - Stefan-Marr.de

here - Stefan-Marr.de

here - Stefan-Marr.de

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5.1. Open Implementations and Metaobject Protocols<br />

execution. This means it can change state, adapt program structures, or trap<br />

certain operations to refine their behavior. The reified program structures are<br />

referred to as metaobjects. In or<strong>de</strong>r to explain MOPs, Kiczales et al. [1991]<br />

state that in general, a protocol is formed by “a set of object types and operations<br />

on them, which can support not just a single behavior, but a space or region of behaviors”.<br />

T<strong>here</strong>fore, they conclu<strong>de</strong> that a MOP enables the encoding of individual<br />

<strong>de</strong>cisions about language behavior via the operations of metaobjects.<br />

Categories of MOPs Tanter [2009, p. 12] distinguishes metaobject protocols<br />

(MOPs) for object-oriented reflection by the correspon<strong>de</strong>nce of the meta relation<br />

to other aspects of the system. He i<strong>de</strong>ntifies a number of common i<strong>de</strong>as:<br />

metaclass-based mo<strong>de</strong>ls, metaobject-based mo<strong>de</strong>ls, group-based mo<strong>de</strong>ls, and<br />

message-reification-based mo<strong>de</strong>ls.<br />

Metaclass-based Metaclass-based mo<strong>de</strong>ls such as in CLOS, Perl’s Moose,<br />

or Smalltalk enable for instance the customization of method dispatch or<br />

object fields semantics. The metaclass of a class t<strong>here</strong>fore <strong>de</strong>scribes the semantics<br />

of this class, i. e., the metaclass’ instance. The meta relation in this<br />

case is the instantiation relationship between a class and its metaclass. This<br />

technique has been used, e. g., to implement persistent objects, which are automatically<br />

mapped to a database [Paepcke, 1993], or even to parallelize programs<br />

[Rodriguez Jr., 1991].<br />

Metaobject-based Metaobject-based mo<strong>de</strong>ls <strong>de</strong>couple meta interfaces from<br />

the class hierarchy. One example for a language using this mo<strong>de</strong>l is the<br />

prototype-based language 3-KRS [Maes, 1987]. Since 3-KRS does not have the<br />

notion of classes, it is <strong>de</strong>signed with a one-to-one relation between a base-level<br />

object and a metaobject. However, the mo<strong>de</strong>l can be applied to class-based languages,<br />

for instance as is the case in Albedo, a Smalltalk system [Ressia et al.,<br />

2010]. The in<strong>de</strong>pen<strong>de</strong>nce from the class hierarchy enables modifications that<br />

are orthogonal to the class hierarchy and results in a mo<strong>de</strong>l with greater flexibility.<br />

Instead of having a one-to-one mapping, other variations of the mo<strong>de</strong>l are<br />

possible as well. One common example is proxy-based MOPs, for instance<br />

as the one proposed for the next version of ECMAScript [Van Cutsem and<br />

Miller, 2010]. 3 Metaobjects are <strong>de</strong>fined in the form of proxy objects that reify<br />

3 Direct Proxies, Tom Van Cutsem, access date: 4 July 2012<br />

http://wiki.ecmascript.org/doku.php?id=harmony:direct_proxies<br />

111

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!