[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
3.5.3 Extending Guile's Primitives
When GOOPS is loaded, many of Guile's primitive procedures can be extended by giving them a generic function definition that operates in conjunction with their normal C-coded implementation. For primitives that are extended in this way, the result from the user- or application-level point of view is that the extended primitive behaves exactly like a generic function with the C-coded implementation as its default method.
The generic-capability?
predicate should be used to determine
whether a particular primitive is extensible in this way.
- primitive procedure: generic-capability? primitive
Return
#t
if primitive can be extended by giving it a generic function definition, otherwise#f
.
Even when a primitive procedure is extensible like this, its generic
function definition is not created until it is needed by a call to
define-method
, or until the application explicitly requests it
by calling enable-primitive-generic!
.
- primitive procedure: enable-primitive-generic! primitive
Force the creation of a generic function definition for primitive.
Once the generic function definition for a primitive has been created,
it can be retrieved using primitive-generic-generic
.
- primitive procedure: primitive-generic-generic primitive
Return the generic function definition of primitive.
primitive-generic-generic
raises an error if primitive is not a primitive with generic capability, or if its generic capability has not yet been enabled, whether implicitly (bydefine-method
) or explicitly (byenable-primitive-generic!
).
Note that the distinction between, on the one hand, primitives with additional generic function definitions and, on the other hand, generic functions with a default method, may disappear when GOOPS is fully integrated into the core of Guile. Consequently, the procedures described in this section may disappear as well.