1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-29 22:40:34 +02:00

Edit text about the MOP

* doc/ref/goops.texi (The Metaobject Protocol, Metaobjects and the
  Metaobject Protocol): Minor edits.
This commit is contained in:
Neil Jerram 2010-09-25 17:27:14 +01:00
parent a9bf12c2e5
commit 5aaf0709e6

View file

@ -2156,29 +2156,21 @@ as the Guile primitive @code{write} and @code{display} functions.
@node The Metaobject Protocol @node The Metaobject Protocol
@section The Metaobject Protocol @section The Metaobject Protocol
GOOPS is based on a ``metaobject protocol'' derived from the ones used GOOPS is based on a ``metaobject protocol'' (aka ``MOP'') derived from
in CLOS (the Common Lisp Object System), tiny-clos (a small Scheme the ones used in CLOS (the Common Lisp Object System), tiny-clos (a
implementation of a subset of CLOS functionality) and STKlos. small Scheme implementation of a subset of CLOS functionality) and
STKlos.
GOOPS can be used by application authors at a basic level without any GOOPS can be used by application authors at a basic level without any
need to understand what the metaobject protocol (aka ``MOP'') is and how need to understand what the MOP is and how it works. On the other hand,
it works. On the other hand, the MOP underlies even the customizations the MOP underlies even very simple customizations --- such as defining
that application authors are likely to make use of very quickly --- such an @code{initialize} method to customize the initialization of instances
as defining an @code{initialize} method to customize the initialization of an application-defined class --- and an understanding of the MOP
of instances of an application-defined class --- and an understanding of makes it much easier to explain such customizations in a precise way.
the MOP makes it much easier to explain such customizations in a precise And in the long run, understanding the MOP is the key both to
way. And in the long run, understanding the MOP is the key both to
understanding GOOPS at a deeper level and to taking full advantage of understanding GOOPS at a deeper level and to taking full advantage of
GOOPS' power, by customizing the behaviour of GOOPS itself. GOOPS' power, by customizing the behaviour of GOOPS itself.
These introductory remarks continue with a few words about metaobjects
and the MOP.
In general, this reference manual assumes familiarity with standard
object oriented concepts and terminology. However, some of the terms
used in GOOPS are less well known, so the Terminology subsubsection
provides definitions for these terms.
@menu @menu
* Metaobjects and the Metaobject Protocol:: * Metaobjects and the Metaobject Protocol::
* Terminology:: * Terminology::
@ -2193,10 +2185,10 @@ provides definitions for these terms.
@node Metaobjects and the Metaobject Protocol @node Metaobjects and the Metaobject Protocol
@subsection Metaobjects and the Metaobject Protocol @subsection Metaobjects and the Metaobject Protocol
The conceptual building blocks of GOOPS are classes, slot definitions, The building blocks of GOOPS are classes, slot definitions, instances,
instances, generic functions and methods. A class is a grouping of generic functions and methods. A class is a grouping of inheritance
inheritance relations and slot definitions. An instance is an object relations and slot definitions. An instance is an object with slots
with slots that are allocated following the rules implied by its class's that are allocated following the rules implied by its class's
superclasses and slot definitions. A generic function is a collection superclasses and slot definitions. A generic function is a collection
of methods and rules for determining which of those methods to apply of methods and rules for determining which of those methods to apply
when the generic function is invoked. A method is a procedure and a set when the generic function is invoked. A method is a procedure and a set
@ -2238,9 +2230,9 @@ of steps is as follows.
@itemize @bullet @itemize @bullet
@item @item
@code{define-class} uses @code{make} to make a new instance of the @code{define-class} uses @code{make} to make a new instance of the
@code{<class>}, passing as initialization arguments the superclasses, @code{<class>} class, passing as initialization arguments the
slot definitions and class options that were specified in the superclasses, slot definitions and class options that were specified in
@code{define-class} form. the @code{define-class} form.
@item @item
@code{make} allocates memory for the new instance, and then invokes the @code{make} allocates memory for the new instance, and then invokes the
@ -2282,23 +2274,22 @@ of that class.
Such is the power of the MOP. Note that @code{initialize} is just one Such is the power of the MOP. Note that @code{initialize} is just one
of a large number of generic functions that can be customized to modify of a large number of generic functions that can be customized to modify
the behaviour of application objects and classes and of GOOPS itself. the behaviour of application objects and classes and of GOOPS itself.
Each subsequent section of the reference manual covers a particular area Each following section covers a particular area of GOOPS functionality,
of GOOPS functionality, and describes the generic functions that are and describes the generic functions that are relevant for customization
relevant for customization of that area. of that area.
We conclude this subsubsection by emphasizing a point that may seem We conclude these remarks by emphasizing a point that may seem obvious,
obvious, but contrasts with the corresponding situation in some other but contrasts with the corresponding situation in some other MOP
MOP implementations, such as CLOS. The point is simply that an implementations, such as CLOS. The point is simply that an identifier
identifier which represents a GOOPS class or generic function is a which represents a GOOPS class or generic function is a variable with a
variable with a first-class value, the value being an instance of class first-class value, the value being an instance of class @code{<class>}
@code{<class>} or @code{<generic>}. (In CLOS, on the other hand, a or @code{<generic>}. (In CLOS, on the other hand, a class identifier is
class identifier is a symbol that indexes the corresponding class a symbol that indexes the corresponding class metaobject in a separate
metaobject in a separate namespace for classes.) This is, of course, namespace for classes.) This is, of course, simply an extension of the
simply an extension of the tendency in Scheme to avoid the unnecessary tendency in Scheme to avoid the unnecessary use of, on the one hand,
use of, on the one hand, syntactic forms that require unevaluated syntactic forms that require unevaluated arguments and, on the other,
arguments and, on the other, separate identifier namespaces (e.g. for separate identifier namespaces (e.g. for class names), but it is worth
class names), but it is worth noting that GOOPS conforms fully to this noting that GOOPS conforms fully to this Schemely principle.
Schemely principle.
@node Terminology @node Terminology
@subsection Terminology @subsection Terminology