chickadee » chibi-generic


Chibi Scheme's simple generic function interface

Original page here:


(define-generic name)syntax

Define a new generic function named name.

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

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.

make-generic nameprocedure

Create a new first-class generic function named name.

generic-add! g preds fprocedure

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

Contents »