guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, master, updated. release_1-9-12-126-g1


From: Neil Jerram
Subject: [Guile-commits] GNU Guile branch, master, updated. release_1-9-12-126-g1905db2
Date: Sat, 02 Oct 2010 17:19:17 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=1905db2b48bc7cdd97c91fea35382de00ce2060a

The branch, master has been updated
       via  1905db2b48bc7cdd97c91fea35382de00ce2060a (commit)
       via  9e57815ddf0434e637e0a413da2ab32ad5d96e23 (commit)
       via  3dc071e483dc5656d88c58be2d84de0e18ec78b2 (commit)
       via  a8f8d5b11f10a115f1c38f6983112bdcf6498dac (commit)
       via  58ad1de7b1a609fea457220a8fc4d26ea34fe9dd (commit)
      from  2c5fc8d03420855301993bee6d8afa28d64503d6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1905db2b48bc7cdd97c91fea35382de00ce2060a
Author: Neil Jerram <address@hidden>
Date:   Sat Oct 2 16:24:14 2010 +0100

    Flatten `Miscellaneous Functions'
    
    * doc/ref/goops.texi (Miscellaneous Functions): Delete this container
      section, and promote its subsections.

commit 9e57815ddf0434e637e0a413da2ab32ad5d96e23
Author: Neil Jerram <address@hidden>
Date:   Sat Oct 2 16:12:32 2010 +0100

    Customizing Instance Creation to metaobject protocol section
    
    * doc/ref/goops.texi (Customizing Instance Creation): Moved from
      `Creating Instances' to `The Metaobject Protocol'.
    
    * doc/ref/goops.texi (Basic Instance Creation): Flattened into parent
      `Creating Instances', refs updated accordingly.

commit 3dc071e483dc5656d88c58be2d84de0e18ec78b2
Author: Neil Jerram <address@hidden>
Date:   Sat Oct 2 16:10:56 2010 +0100

    Remove goops-version, which is no longer defined
    
    * doc/ref/goops.texi (Administrative Functions): Removed.
    
    * module/oop/goops.scm (oop): Don't export `goops-version'.

commit a8f8d5b11f10a115f1c38f6983112bdcf6498dac
Author: Neil Jerram <address@hidden>
Date:   Sat Oct 2 15:39:14 2010 +0100

    Remove doc of STKlos compatibility
    
    As module/oop/goops/stklos.scm, the available compatibility is
    superficial only, so it isn't worth documenting.
    
    * doc/ref/goops.texi (STKlos Compatibility): Removed.

commit 58ad1de7b1a609fea457220a8fc4d26ea34fe9dd
Author: Neil Jerram <address@hidden>
Date:   Sat Oct 2 15:36:46 2010 +0100

    Continue separating simple and more complex GOOPS doc
    
    * doc/ref/goops.texi (Defining New Classes): Move `Class Definition
      Internals' and `Customizing Class Definition' notes to the
      metaobject protocol section.

-----------------------------------------------------------------------

Summary of changes:
 doc/ref/goops.texi   |  696 ++++++++++++++++++++++++--------------------------
 module/oop/goops.scm |    2 +-
 2 files changed, 330 insertions(+), 368 deletions(-)

diff --git a/doc/ref/goops.texi b/doc/ref/goops.texi
index 9a7e774..e0a0088 100644
--- a/doc/ref/goops.texi
+++ b/doc/ref/goops.texi
@@ -41,7 +41,10 @@ overriding or redefining those methods.
 * Redefining a Class::
 * Changing the Class of an Instance::
 * Introspection::
-* Miscellaneous Functions::
+* GOOPS Error Handling::
+* Object Comparisons::
+* Cloning Objects::
+* Write and Display::
 * The Metaobject Protocol::
 @end menu
 
@@ -255,9 +258,6 @@ subsections.
 @menu
 * Slot Options::
 * Class Options::
-* Class Definition Internals::
-* Customizing Class Definition::
-* STKlos Compatibility::
 @end menu
 
 @node Slot Options
@@ -495,279 +495,9 @@ If the @code{#:name} option is absent, GOOPS uses the 
first argument to
 @code{define-class} as the class name.
 @end deffn
 
address@hidden Class Definition Internals
address@hidden Class Definition Internals
-
-Implementation notes: @code{define-class} expands to an expression which
-
address@hidden @bullet
address@hidden
-checks that it is being evaluated only at top level
-
address@hidden
-defines any accessors that are implied by the @var{slot-definition}s
-
address@hidden
-uses @code{class} to create the new class (@pxref{Class Definition
-Internals,, class})
-
address@hidden
-checks for a previous class definition for @var{name} and, if found,
-handles the redefinition by invoking @code{class-redefinition}
-(@pxref{Redefining a Class}).
address@hidden itemize
-
address@hidden syntax class name (super @dots{}) slot-definition @dots{} . 
options
-Return a newly created class that inherits from @var{super}s, with
-direct slots defined by @var{slot-definition}s and class options
address@hidden  For the format of @var{slot-definition}s and
address@hidden, see @ref{Defining New Classes,, define-class}.
address@hidden deffn
-
-Implementation notes: @code{class} expands to an expression which
-
address@hidden @bullet
address@hidden
-processes the class and slot definition options to check that they are
-well-formed, to convert the @code{#:init-form} option to an
address@hidden:init-thunk} option, to supply a default environment parameter
-(the current top-level environment) and to evaluate all the bits that
-need to be evaluated
-
address@hidden
-calls @code{make-class} to create the class with the processed and
-evaluated parameters.
address@hidden itemize
-
address@hidden procedure make-class supers slots . options
-Return a newly created class that inherits from @var{supers}, with
-direct slots defined by @var{slots} and class options @var{options}.
-For the format of @var{slots} and @var{options}, see @ref{Defining New
-Classes,, define-class}, except note that for @code{make-class},
address@hidden and @var{options} are separate list parameters: @var{slots}
-here is a list of slot definitions.
address@hidden deffn
-
-Implementation notes: @code{make-class}
-
address@hidden @bullet
address@hidden
-adds @code{<object>} to the @var{supers} list if @var{supers} is empty
-or if none of the classes in @var{supers} have @code{<object>} in their
-class precedence list
-
address@hidden
-defaults the @code{#:environment}, @code{#:name} and @code{#:metaclass}
-options, if they are not specified by @var{options}, to the current
-top-level environment, the unbound value, and @code{(ensure-metaclass
address@hidden)} respectively (@pxref{Class Definition Internals,,
-ensure-metaclass})
-
address@hidden
-checks for duplicate classes in @var{supers} and duplicate slot names in
address@hidden, and signals an error if there are any duplicates
-
address@hidden
-calls @code{make}, passing the metaclass as the first parameter and all
-other parameters as option keywords with values.
address@hidden itemize
-
address@hidden procedure ensure-metaclass supers env
-Return a metaclass suitable for a class that inherits from the list of
-classes in @var{supers}.  The returned metaclass is the union by
-inheritance of the metaclasses of the classes in @var{supers}.
-
-In the simplest case, where all the @var{supers} are straightforward
-classes with metaclass @code{<class>}, the returned metaclass is just
address@hidden<class>}.
-
-For a more complex example, suppose that @var{supers} contained one
-class with metaclass @code{<operator-class>} and one with metaclass
address@hidden<foreign-object-class>}.  Then the returned metaclass would be a
-class that inherits from both @code{<operator-class>} and
address@hidden<foreign-object-class>}.
-
-If @var{supers} is the empty list, @code{ensure-metaclass} returns the
-default GOOPS metaclass @code{<class>}.
-
-GOOPS keeps a list of the metaclasses created by
address@hidden, so that each required type of metaclass only
-has to be created once.
-
-The @code{env} parameter is ignored.
address@hidden deffn
-
address@hidden procedure ensure-metaclass-with-supers meta-supers
address@hidden is an internal procedure used by
address@hidden (@pxref{Class Definition Internals,,
-ensure-metaclass}).  It returns a metaclass that is the union by
-inheritance of the metaclasses in @var{meta-supers}.
address@hidden deffn
-
-The internals of @code{make}, which is ultimately used to create the new
-class object, are described in @ref{Customizing Instance Creation},
-which covers the creation and initialization of instances in general.
-
address@hidden Customizing Class Definition
address@hidden Customizing Class Definition
-
-During the initialization of a new class, GOOPS calls a number of generic
-functions with the newly allocated class instance as the first
-argument.  Specifically, GOOPS calls the generic function
-
address@hidden @bullet
address@hidden
-(initialize @var{class} @dots{})
address@hidden itemize
-
-where @var{class} is the newly allocated class instance, and the default
address@hidden method for arguments of type @code{<class>} calls the
-generic functions
-
address@hidden @bullet
address@hidden
-(compute-cpl @var{class})
-
address@hidden
-(compute-slots @var{class})
-
address@hidden
-(compute-get-n-set @var{class} @var{slot-def}), for each of the slot
-definitions returned by @code{compute-slots}
-
address@hidden
-(compute-getter-method @var{class} @var{slot-def}), for each of the
-slot definitions returned by @code{compute-slots} that includes a
address@hidden:getter} or @code{#:accessor} slot option
-
address@hidden
-(compute-setter-method @var{class} @var{slot-def}), for each of the
-slot definitions returned by @code{compute-slots} that includes a
address@hidden:setter} or @code{#:accessor} slot option.
address@hidden itemize
-
-If the metaclass of the new class is something more specialized than the
-default @code{<class>}, then the type of @var{class} in the calls above
-is more specialized than @code{<class>}, and hence it becomes possible
-to define generic function methods, specialized for the new class's
-metaclass, that can modify or override the default behaviour of
address@hidden, @code{compute-cpl} or @code{compute-get-n-set}.
-
address@hidden computes the class precedence list (``CPL'') for the
-new class (@pxref{Class precedence list}), and returns it as a list of
-class objects.  The CPL is important because it defines a superclass
-ordering that is used, when a generic function is invoked upon an
-instance of the class, to decide which of the available generic function
-methods is the most specific.  Hence @code{compute-cpl} could be
-customized in order to modify the CPL ordering algorithm for all classes
-with a special metaclass.
-
-The default CPL algorithm is encapsulated by the @code{compute-std-cpl}
-procedure, which is in turn called by the default @code{compute-cpl}
-method.
-
address@hidden procedure compute-std-cpl class
-Compute and return the class precedence list for @var{class} according
-to the algorithm described in @ref{Class precedence list}.
address@hidden deffn
-
address@hidden computes and returns a list of all slot definitions
-for the new class.  By default, this list includes the direct slot
-definitions from the @code{define-class} form, plus the slot definitions
-that are inherited from the new class's superclasses.  The default
address@hidden method uses the CPL computed by @code{compute-cpl}
-to calculate this union of slot definitions, with the rule that slots
-inherited from superclasses are shadowed by direct slots with the same
-name.  One possible reason for customizing @code{compute-slots} would be
-to implement an alternative resolution strategy for slot name conflicts.
-
address@hidden computes the low-level closures that will be
-used to get and set the value of a particular slot, and returns them in
-a list with two elements.
-
-The closures returned depend on how storage for that slot is allocated.
-The standard @code{compute-get-n-set} method, specialized for classes of
-type @code{<class>}, handles the standard GOOPS values for the
address@hidden:allocation} slot option (@pxref{Slot Options,, allocation}).  By
-defining a new @code{compute-get-n-set} method for a more specialized
-metaclass, it is possible to support new types of slot allocation.
-
-Suppose you wanted to create a large number of instances of some class
-with a slot that should be shared between some but not all instances of
-that class - say every 10 instances should share the same slot storage.
-The following example shows how to implement and use a new type of slot
-allocation to do this.
-
address@hidden
-(define-class <batched-allocation-metaclass> (<class>))
-
-(let ((batch-allocation-count 0)
-      (batch-get-n-set #f))
-  (define-method (compute-get-n-set
-                     (class <batched-allocation-metaclass>) s)
-    (case (slot-definition-allocation s)
-      ((#:batched)
-       ;; If we've already used the same slot storage for 10 instances,
-       ;; reset variables.
-       (if (= batch-allocation-count 10)
-           (begin
-             (set! batch-allocation-count 0)
-             (set! batch-get-n-set #f)))
-       ;; If we don't have a current pair of get and set closures,
-       ;; create one.  make-closure-variable returns a pair of closures
-       ;; around a single Scheme variable - see goops.scm for details.
-       (or batch-get-n-set
-           (set! batch-get-n-set (make-closure-variable)))
-       ;; Increment the batch allocation count.
-       (set! batch-allocation-count (+ batch-allocation-count 1))
-       batch-get-n-set)
-
-      ;; Call next-method to handle standard allocation types.
-      (else (next-method)))))
-
-(define-class <class-using-batched-slot> ()
-  ...
-  (c #:allocation #:batched)
-  ...
-  #:metaclass <batched-allocation-metaclass>)
address@hidden example
-
-The usage of @code{compute-getter-method} and @code{compute-setter-method}
-is described in @ref{MOP Specification}.
-
address@hidden and @code{compute-get-n-set} are called by the
-standard @code{initialize} method for classes whose metaclass is
address@hidden<class>}.  But @code{initialize} itself can also be modified, by
-defining an @code{initialize} method specialized to the new class's
-metaclass.  Such a method could complete override the standard
-behaviour, by not calling @code{(next-method)} at all, but more
-typically it would perform additional class initialization steps before
-and/or after calling @code{(next-method)} for the standard behaviour.
-
address@hidden STKlos Compatibility
address@hidden STKlos Compatibility
-
-If the STKlos compatibility module is loaded, @code{define-class} is
-overwritten by a STKlos-specific definition; the standard GOOPS
-definition of @code{define-class} remains available in
address@hidden
-
address@hidden syntax standard-define-class name (super @dots{}) 
slot-definition @dots{} . options
address@hidden is equivalent to the standard GOOPS
address@hidden
address@hidden deffn
-
 @node Creating Instances
 @section Creating Instances
 
address@hidden
-* Basic Instance Creation::
-* Customizing Instance Creation::
address@hidden menu
-
address@hidden Basic Instance Creation
address@hidden Basic Instance Creation
-
 To create a new instance of any GOOPS class, use the generic function
 @code{make} or @code{make-instance}, passing the required class and any
 appropriate instance initialization arguments as keyword and value
@@ -802,73 +532,6 @@ instance's class.  Any unprocessed keyword value pairs are 
ignored.
 @code{make-instance} is an alias for @code{make}.
 @end deffn
 
address@hidden Customizing Instance Creation
address@hidden Customizing Instance Creation
-
address@hidden itself is a generic function.  Hence the @code{make}
-invocation itself can be customized in the case where the new instance's
-metaclass is more specialized than the default @code{<class>}, by
-defining a @code{make} method that is specialized to that metaclass.
-
-Normally, however, the method for classes with metaclass @code{<class>}
-will be applied.  This method calls two generic functions:
-
address@hidden @bullet
address@hidden
-(allocate-instance @var{class} . @var{initargs})
-
address@hidden
-(initialize @var{instance} . @var{initargs})
address@hidden itemize
-
address@hidden allocates storage for and returns the new
-instance, uninitialized.  You might customize @code{allocate-instance},
-for example, if you wanted to provide a GOOPS wrapper around some other
-object programming system.
-
-To do this, you would create a specialized metaclass, which would act as
-the metaclass for all classes and instances from the other system.  Then
-define an @code{allocate-instance} method, specialized to that
-metaclass, which calls a Guile primitive C function, which in turn
-allocates the new instance using the interface of the other object
-system.
-
-In this case, for a complete system, you would also need to customize a
-number of other generic functions like @code{make} and
address@hidden, so that GOOPS knows how to make classes from the
-other system, access instance slots, and so on.
-
address@hidden initializes the instance that is returned by
address@hidden  The standard GOOPS methods perform
-initializations appropriate to the instance class.
-
address@hidden @bullet
address@hidden
-At the least specialized level, the method for instances of type
address@hidden<object>} performs internal GOOPS instance initialization, and
-initializes the instance's slots according to the slot definitions and
-any slot initialization keywords that appear in @var{initargs}.
-
address@hidden
-The method for instances of type @code{<class>} calls
address@hidden(next-method)}, then performs the class initializations described
-in @ref{Customizing Class Definition}.
-
address@hidden
-and so on for generic functions, method, operator classes @dots{}
address@hidden itemize
-
-Similarly, you can customize the initialization of instances of any
-application-defined class by defining an @code{initialize} method
-specialized to that class.
-
-Imagine a class whose instances' slots need to be initialized at
-instance creation time by querying a database.  Although it might be
-possible to achieve this a combination of @code{#:init-thunk} keywords
-and closures in the slot definitions, it is neater to write an
address@hidden method for the class that queries the database once
-and initializes all the dependent slot values according to the results.
-
 @node Accessing Slots
 @section Accessing Slots
 
@@ -1572,7 +1235,7 @@ default method calls @code{goops-error} with an 
appropriate message.
 Suppose that a class @code{<my-class>} is defined using @code{define-class}
 (@pxref{Defining New Classes,, define-class}), with slots that have
 accessor functions, and that an application has created several instances
-of @code{<my-class>} using @code{make} (@pxref{Basic Instance Creation,,
+of @code{<my-class>} using @code{make} (@pxref{Creating Instances,,
 make}).  What then happens if @code{<my-class>} is redefined by calling
 @code{define-class} again?
 
@@ -1591,7 +1254,7 @@ GOOPS' default answer to this question is as follows.
 All existing direct instances of @code{<my-class>} are converted to be
 instances of the new class.  This is achieved by preserving the values
 of slots that exist in both the old and new definitions, and initializing the
-values of new slots in the usual way (@pxref{Basic Instance Creation,,
+values of new slots in the usual way (@pxref{Creating Instances,,
 make}).
 
 @item
@@ -1989,28 +1652,8 @@ Return an expression that prints to show the definition 
of method
 @end example
 @end deffn
 
address@hidden Miscellaneous Functions
address@hidden Miscellaneous Functions
-
address@hidden
-* Administrative Functions::
-* GOOPS Error Handling::
-* Object Comparisons::
-* Cloning Objects::
-* Write and Display::
address@hidden menu
-
address@hidden Administrative Functions
address@hidden Administration Functions
-
-This section describes administrative, non-technical GOOPS functions.
-
address@hidden primitive goops-version
-Return the current GOOPS version as a string, for example ``0.2''.
address@hidden deffn
-
 @node GOOPS Error Handling
address@hidden Error Handling
address@hidden Error Handling
 
 The procedure @code{goops-error} is called to raise an appropriate error
 by the default methods of the following generic functions:
@@ -2045,7 +1688,7 @@ as done by @code{scm-error}.
 @end deffn
 
 @node Object Comparisons
address@hidden Object Comparisons
address@hidden Object Comparisons
 
 @deffn generic eqv?
 @deffnx method eqv? ((x <top>) (y <top>))
@@ -2074,7 +1717,7 @@ and the Guile reference manual.
 @end deffn
 
 @node Cloning Objects
address@hidden Cloning Objects
address@hidden Cloning Objects
 
 @deffn generic shallow-clone
 @deffnx method shallow-clone (self <object>)
@@ -2095,7 +1738,7 @@ or by reference.
 @end deffn
 
 @node Write and Display
address@hidden Write and Display
address@hidden Write and Display
 
 @deffn {primitive generic} write object port
 @deffnx {primitive generic} display object port
@@ -2146,7 +1789,10 @@ GOOPS' power, by customizing the behaviour of GOOPS 
itself.
 * Terminology::
 * MOP Specification::
 * Class Definition::
+* Class Definition Internals::
+* Customizing Class Definition::
 * Instance Creation::
+* Customizing Instance Creation::
 * Class Redefinition::
 * Method Definition::
 * Generic Function Invocation::
@@ -2607,6 +2253,255 @@ to the generic function named by the slot definition's 
@code{#:setter}
 or @code{#:accessor} option.
 @end itemize
 
address@hidden Class Definition Internals
address@hidden Class Definition Internals
+
address@hidden expands to an expression which
+
address@hidden @bullet
address@hidden
+checks that it is being evaluated only at top level
+
address@hidden
+defines any accessors that are implied by the @var{slot-definition}s
+
address@hidden
+uses @code{class} to create the new class (@pxref{Class Definition
+Internals,, class})
+
address@hidden
+checks for a previous class definition for @var{name} and, if found,
+handles the redefinition by invoking @code{class-redefinition}
+(@pxref{Redefining a Class}).
address@hidden itemize
+
address@hidden syntax class name (super @dots{}) slot-definition @dots{} . 
options
+Return a newly created class that inherits from @var{super}s, with
+direct slots defined by @var{slot-definition}s and class options
address@hidden  For the format of @var{slot-definition}s and
address@hidden, see @ref{Defining New Classes,, define-class}.
address@hidden deffn
+
address@hidden @code{class} expands to an expression which
+
address@hidden @bullet
address@hidden
+processes the class and slot definition options to check that they are
+well-formed, to convert the @code{#:init-form} option to an
address@hidden:init-thunk} option, to supply a default environment parameter
+(the current top-level environment) and to evaluate all the bits that
+need to be evaluated
+
address@hidden
+calls @code{make-class} to create the class with the processed and
+evaluated parameters.
address@hidden itemize
+
address@hidden procedure make-class supers slots . options
+Return a newly created class that inherits from @var{supers}, with
+direct slots defined by @var{slots} and class options @var{options}.
+For the format of @var{slots} and @var{options}, see @ref{Defining New
+Classes,, define-class}, except note that for @code{make-class},
address@hidden and @var{options} are separate list parameters: @var{slots}
+here is a list of slot definitions.
address@hidden deffn
+
address@hidden @code{make-class}
+
address@hidden @bullet
address@hidden
+adds @code{<object>} to the @var{supers} list if @var{supers} is empty
+or if none of the classes in @var{supers} have @code{<object>} in their
+class precedence list
+
address@hidden
+defaults the @code{#:environment}, @code{#:name} and @code{#:metaclass}
+options, if they are not specified by @var{options}, to the current
+top-level environment, the unbound value, and @code{(ensure-metaclass
address@hidden)} respectively (@pxref{Class Definition Internals,,
+ensure-metaclass})
+
address@hidden
+checks for duplicate classes in @var{supers} and duplicate slot names in
address@hidden, and signals an error if there are any duplicates
+
address@hidden
+calls @code{make}, passing the metaclass as the first parameter and all
+other parameters as option keywords with values.
address@hidden itemize
+
address@hidden procedure ensure-metaclass supers env
+Return a metaclass suitable for a class that inherits from the list of
+classes in @var{supers}.  The returned metaclass is the union by
+inheritance of the metaclasses of the classes in @var{supers}.
+
+In the simplest case, where all the @var{supers} are straightforward
+classes with metaclass @code{<class>}, the returned metaclass is just
address@hidden<class>}.
+
+For a more complex example, suppose that @var{supers} contained one
+class with metaclass @code{<operator-class>} and one with metaclass
address@hidden<foreign-object-class>}.  Then the returned metaclass would be a
+class that inherits from both @code{<operator-class>} and
address@hidden<foreign-object-class>}.
+
+If @var{supers} is the empty list, @code{ensure-metaclass} returns the
+default GOOPS metaclass @code{<class>}.
+
+GOOPS keeps a list of the metaclasses created by
address@hidden, so that each required type of metaclass only
+has to be created once.
+
+The @code{env} parameter is ignored.
address@hidden deffn
+
address@hidden procedure ensure-metaclass-with-supers meta-supers
address@hidden is an internal procedure used by
address@hidden (@pxref{Class Definition Internals,,
+ensure-metaclass}).  It returns a metaclass that is the union by
+inheritance of the metaclasses in @var{meta-supers}.
address@hidden deffn
+
+The internals of @code{make}, which is ultimately used to create the new
+class object, are described in @ref{Customizing Instance Creation},
+which covers the creation and initialization of instances in general.
+
address@hidden Customizing Class Definition
address@hidden Customizing Class Definition
+
+During the initialization of a new class, GOOPS calls a number of generic
+functions with the newly allocated class instance as the first
+argument.  Specifically, GOOPS calls the generic function
+
address@hidden @bullet
address@hidden
+(initialize @var{class} @dots{})
address@hidden itemize
+
+where @var{class} is the newly allocated class instance, and the default
address@hidden method for arguments of type @code{<class>} calls the
+generic functions
+
address@hidden @bullet
address@hidden
+(compute-cpl @var{class})
+
address@hidden
+(compute-slots @var{class})
+
address@hidden
+(compute-get-n-set @var{class} @var{slot-def}), for each of the slot
+definitions returned by @code{compute-slots}
+
address@hidden
+(compute-getter-method @var{class} @var{slot-def}), for each of the
+slot definitions returned by @code{compute-slots} that includes a
address@hidden:getter} or @code{#:accessor} slot option
+
address@hidden
+(compute-setter-method @var{class} @var{slot-def}), for each of the
+slot definitions returned by @code{compute-slots} that includes a
address@hidden:setter} or @code{#:accessor} slot option.
address@hidden itemize
+
+If the metaclass of the new class is something more specialized than the
+default @code{<class>}, then the type of @var{class} in the calls above
+is more specialized than @code{<class>}, and hence it becomes possible
+to define generic function methods, specialized for the new class's
+metaclass, that can modify or override the default behaviour of
address@hidden, @code{compute-cpl} or @code{compute-get-n-set}.
+
address@hidden computes the class precedence list (``CPL'') for the
+new class (@pxref{Class precedence list}), and returns it as a list of
+class objects.  The CPL is important because it defines a superclass
+ordering that is used, when a generic function is invoked upon an
+instance of the class, to decide which of the available generic function
+methods is the most specific.  Hence @code{compute-cpl} could be
+customized in order to modify the CPL ordering algorithm for all classes
+with a special metaclass.
+
+The default CPL algorithm is encapsulated by the @code{compute-std-cpl}
+procedure, which is in turn called by the default @code{compute-cpl}
+method.
+
address@hidden procedure compute-std-cpl class
+Compute and return the class precedence list for @var{class} according
+to the algorithm described in @ref{Class precedence list}.
address@hidden deffn
+
address@hidden computes and returns a list of all slot definitions
+for the new class.  By default, this list includes the direct slot
+definitions from the @code{define-class} form, plus the slot definitions
+that are inherited from the new class's superclasses.  The default
address@hidden method uses the CPL computed by @code{compute-cpl}
+to calculate this union of slot definitions, with the rule that slots
+inherited from superclasses are shadowed by direct slots with the same
+name.  One possible reason for customizing @code{compute-slots} would be
+to implement an alternative resolution strategy for slot name conflicts.
+
address@hidden computes the low-level closures that will be
+used to get and set the value of a particular slot, and returns them in
+a list with two elements.
+
+The closures returned depend on how storage for that slot is allocated.
+The standard @code{compute-get-n-set} method, specialized for classes of
+type @code{<class>}, handles the standard GOOPS values for the
address@hidden:allocation} slot option (@pxref{Slot Options,, allocation}).  By
+defining a new @code{compute-get-n-set} method for a more specialized
+metaclass, it is possible to support new types of slot allocation.
+
+Suppose you wanted to create a large number of instances of some class
+with a slot that should be shared between some but not all instances of
+that class - say every 10 instances should share the same slot storage.
+The following example shows how to implement and use a new type of slot
+allocation to do this.
+
address@hidden
+(define-class <batched-allocation-metaclass> (<class>))
+
+(let ((batch-allocation-count 0)
+      (batch-get-n-set #f))
+  (define-method (compute-get-n-set
+                     (class <batched-allocation-metaclass>) s)
+    (case (slot-definition-allocation s)
+      ((#:batched)
+       ;; If we've already used the same slot storage for 10 instances,
+       ;; reset variables.
+       (if (= batch-allocation-count 10)
+           (begin
+             (set! batch-allocation-count 0)
+             (set! batch-get-n-set #f)))
+       ;; If we don't have a current pair of get and set closures,
+       ;; create one.  make-closure-variable returns a pair of closures
+       ;; around a single Scheme variable - see goops.scm for details.
+       (or batch-get-n-set
+           (set! batch-get-n-set (make-closure-variable)))
+       ;; Increment the batch allocation count.
+       (set! batch-allocation-count (+ batch-allocation-count 1))
+       batch-get-n-set)
+
+      ;; Call next-method to handle standard allocation types.
+      (else (next-method)))))
+
+(define-class <class-using-batched-slot> ()
+  ...
+  (c #:allocation #:batched)
+  ...
+  #:metaclass <batched-allocation-metaclass>)
address@hidden example
+
+The usage of @code{compute-getter-method} and @code{compute-setter-method}
+is described in @ref{MOP Specification}.
+
address@hidden and @code{compute-get-n-set} are called by the
+standard @code{initialize} method for classes whose metaclass is
address@hidden<class>}.  But @code{initialize} itself can also be modified, by
+defining an @code{initialize} method specialized to the new class's
+metaclass.  Such a method could complete override the standard
+behaviour, by not calling @code{(next-method)} at all, but more
+typically it would perform additional class initialization steps before
+and/or after calling @code{(next-method)} for the standard behaviour.
+
 @node Instance Creation
 @subsection Instance Creation
 
@@ -2628,6 +2523,73 @@ instance in whatever sense is appropriate for its class. 
 The method's
 return value is ignored.
 @end itemize
 
address@hidden Customizing Instance Creation
address@hidden Customizing Instance Creation
+
address@hidden itself is a generic function.  Hence the @code{make}
+invocation itself can be customized in the case where the new instance's
+metaclass is more specialized than the default @code{<class>}, by
+defining a @code{make} method that is specialized to that metaclass.
+
+Normally, however, the method for classes with metaclass @code{<class>}
+will be applied.  This method calls two generic functions:
+
address@hidden @bullet
address@hidden
+(allocate-instance @var{class} . @var{initargs})
+
address@hidden
+(initialize @var{instance} . @var{initargs})
address@hidden itemize
+
address@hidden allocates storage for and returns the new
+instance, uninitialized.  You might customize @code{allocate-instance},
+for example, if you wanted to provide a GOOPS wrapper around some other
+object programming system.
+
+To do this, you would create a specialized metaclass, which would act as
+the metaclass for all classes and instances from the other system.  Then
+define an @code{allocate-instance} method, specialized to that
+metaclass, which calls a Guile primitive C function, which in turn
+allocates the new instance using the interface of the other object
+system.
+
+In this case, for a complete system, you would also need to customize a
+number of other generic functions like @code{make} and
address@hidden, so that GOOPS knows how to make classes from the
+other system, access instance slots, and so on.
+
address@hidden initializes the instance that is returned by
address@hidden  The standard GOOPS methods perform
+initializations appropriate to the instance class.
+
address@hidden @bullet
address@hidden
+At the least specialized level, the method for instances of type
address@hidden<object>} performs internal GOOPS instance initialization, and
+initializes the instance's slots according to the slot definitions and
+any slot initialization keywords that appear in @var{initargs}.
+
address@hidden
+The method for instances of type @code{<class>} calls
address@hidden(next-method)}, then performs the class initializations described
+in @ref{Customizing Class Definition}.
+
address@hidden
+and so on for generic functions, method, operator classes @dots{}
address@hidden itemize
+
+Similarly, you can customize the initialization of instances of any
+application-defined class by defining an @code{initialize} method
+specialized to that class.
+
+Imagine a class whose instances' slots need to be initialized at
+instance creation time by querying a database.  Although it might be
+possible to achieve this a combination of @code{#:init-thunk} keywords
+and closures in the slot definitions, it is neater to write an
address@hidden method for the class that queries the database once
+and initializes all the dependent slot values according to the results.
+
 @node Class Redefinition
 @subsection Class Redefinition
 
diff --git a/module/oop/goops.scm b/module/oop/goops.scm
index 9ebfab8..70bf375 100644
--- a/module/oop/goops.scm
+++ b/module/oop/goops.scm
@@ -31,7 +31,7 @@
                  define-generic define-accessor define-method
                  define-extended-generic define-extended-generics
                  method)
-  :export (goops-version is-a? class-of
+  :export (is-a? class-of
            ensure-metaclass ensure-metaclass-with-supers
           make-class
           make-generic ensure-generic


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]