1. chibi-generic
    1. Usage

chibi-generic

Chibi Scheme's simple generic function interface

Original page here: http://synthcode.com/scheme/chibi/lib/chibi/generic.html

Usage

[syntax] (define-generic name)

Define a new generic function named name.

[syntax] (define-method (name params ...) body ...)

Each parameter in params should be either a single identifier or a list of the form (param type) where param is the parameter name and type is a predicate which returns true if it's argument is of the correct type. Parameters without a predicate will always match. If multiple methods satisfy the arguments, the most recent method will be used. The special form (call-next-method) can be invoked to call the next most recent method with the same arguments.

[procedure] (make-generic name)

Create a new first-class generic function named name.

[procedure] (generic-add! g preds f)

Extend the generic g with a new method f that applies when all parameters match the given list of predicates preds.