Common Lisp Object System

from Wikipedia, the free encyclopedia

The Common Lisp Object System ( CLOS for short ) is the object-oriented extension of the Common Lisp programming language . It has its origins in loops and flavors , and is specified in the ANSI standard for Common Lisp.

CLOS is (optionally) implemented by the Metaobject Protocol (MOP for short). The MOP is not standardized, but many implementations roughly adhere to the specification from the book The Art of the Metaobject Protocol (see references ), which is often simply referred to as AMOP .

properties

CLOS allows the definition of classes with multiple inheritance , of methods and generic functions .

Since Common Lisp allows interactive and incremental development of programs in a runtime environment , classes can also be changed at runtime. This can e.g. B. can be achieved by manipulating the meta-object protocol, which keeps the instances of the changed classes consistent. This behavior can be adapted by the programmer. In this respect, CLOS is a dynamic and programmable object system.

Another special feature compared to other object-oriented programming languages ​​such as Smalltalk or Java is the fact that methods in CLOS are not assigned to classes, but to separate generic functions.

A generic function comprises a set of methods with different signatures . When the generic function is called for a list of arguments , that method is dynamically selected whose signature fits the arguments most specifically. Generic functions are also called multi- methods because the correct method is not selected based on the first argument (in Smalltalk-like object systems often called the recipient of the message), but based on the entire list of arguments. This behavior, which is elegantly built into CLOS, is nowadays also often reproduced in other languages ​​in the form of so - called aspect orientation .

literature

  • Sonya E. Keene: Object-Oriented Programming in Common Lisp: A Programmer's Guide to CLOS. Addison-Wesley Professional, Boston 1989, ISBN 978-0-201-17589-9
  • Gregor Kiczales, Jim des Rivieres and Daniel G. Bobrow: The Art of the Metaobject Protocol. MIT Press, Boston 1991, ISBN 0-262-61074-4
  • Andreas Paepcke (Editor): Object-Oriented Programming: the CLOS Perspective. MIT Press, Boston 1993, ISBN 0-262-16136-2

Web links