Warning: This is the manual of the legacy Guile 2.2 series. You may want to read the manual of the current stable series instead.
Next: The Metaobject Protocol, Previous: GOOPS Error Handling, Up: GOOPS [Contents][Index]
Here we cover some points about GOOPS objects that aren’t substantial enough to merit sections on their own.
When GOOPS is loaded, eqv?
, equal?
and =
become
generic functions, and you can define methods for them, specialized for
your own classes, so as to control what the various kinds of equality
mean for your classes.
For example, the assoc
procedure, for looking up an entry in an
alist, is specified as using equal?
to determine when the car of
an entry in the alist is the same as the key parameter that assoc
is called with. Hence, if you had defined a new class, and wanted to
use instances of that class as the keys in an alist, you could define a
method for equal?
, for your class, to control assoc
’s
lookup precisely.
Return a “shallow” clone of self. The default method makes a shallow clone by allocating a new instance and copying slot values from self to the new instance. Each slot value is copied either as an immediate value or by reference.
Return a “deep” clone of self. The default method makes a deep
clone by allocating a new instance and copying or cloning slot values
from self to the new instance. If a slot value is an instance
(satisfies instance?
), it is cloned by calling deep-clone
on that value. Other slot values are copied either as immediate values
or by reference.
When GOOPS is loaded, write
and display
become generic
functions with special methods for printing
<object>
<foreign-object>
<class>
<generic>
<method>
.
write
and display
print non-GOOPS values in the same way
as the Guile primitive write
and display
functions.
In addition to the cases mentioned, you can of course define
write
and display
methods for your own classes, to
customize how instances of those classes are printed.
Next: The Metaobject Protocol, Previous: GOOPS Error Handling, Up: GOOPS [Contents][Index]