Warning: This is the manual of the legacy Guile 2.0 series. You may want to read the manual of the current stable series instead.

Next: , Previous: , Up: Methods and Generic Functions   [Contents][Index]

8.6.2 Extending Primitives

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. When a primitive is extended in this way, it behaves like a generic function with the C-coded implementation as its default method.

This extension happens automatically if a method is defined (by a define-method call) for a variable whose current value is a primitive. But it can also be forced 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.