make <class> . initargs (method)
allocate-instance class initargs(generic)
allocate-instance method should allocate storage for
a new instance of class class and return the uninitialized instance.
initialize instance initargs(generic)
instance is the uninitialized instance returned by
allocate-instance. The applied method should initialize the new
instance in whatever sense is appropriate for its class. The method’s
return value is ignored.
make itself is a generic function. Hence the
invocation itself can be customized in the case where the new instance’s
metaclass is more specialized than the default
make method that is specialized to that metaclass.
Normally, however, the method for classes with metaclass
will be applied. This method calls two generic functions:
allocate-instance allocates storage for and returns the new
instance, uninitialized. You might customize
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
allocate-instance method, specialized to that
metaclass, which calls a Guile primitive C function (or FFI code), which
in turn allocates the new instance using the interface of the other
In this case, for a complete system, you would also need to customize a
number of other generic functions like
initialize, so that GOOPS knows how to make classes from the
other system, access instance slots, and so on.
initialize initializes the instance that is returned by
allocate-instance. The standard GOOPS methods perform
initializations appropriate to the instance class.
<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 initargs.
(next-method), then performs the class initializations described in Class Definition Protocol.
Similarly, you can customize the initialization of instances of any
application-defined class by defining an
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
and closures in the slot definitions, it may be neater to write an
initialize method for the class that queries the database once
and initializes all the dependent slot values according to the results.