Generic Function Internals
define-generic calls ensure-generic to upgrade a pre-existing procedure value, or make with metaclass <generic> to create a new generic function.
define-accessor calls ensure-accessor to upgrade a pre-existing procedure value, or make-accessor to create a new accessor.
procedure: ensure-generic old-definition [name]
Return a generic function with name name, if possible by using or upgrading old-definition. If unspecified, name defaults to #f.
If old-definition is already a generic function, it is returned unchanged.
If old-definition is a Scheme procedure or procedure-with-setter, ensure-generic returns a new generic function that uses old-definition for its default procedure and setter.
Otherwise ensure-generic returns a new generic function with no defaults and no methods.
procedure: make-generic [name]
Return a new generic function with name (car name). If unspecified, name defaults to #f.
ensure-generic calls make with metaclasses <generic> and <generic-with-setter>, depending on the previous value of the variable that it is trying to upgrade.
make-generic is a simple wrapper for make with metaclass <generic>.
procedure: ensure-accessor proc [name]
Return an accessor with name name, if possible by using or upgrading proc. If unspecified, name defaults to #f.
If proc is already an accessor, it is returned unchanged.
If proc is a Scheme procedure, procedure-with-setter or generic function, ensure-accessor returns an accessor that reuses the reusable elements of proc.
Otherwise ensure-accessor returns a new accessor with no defaults and no methods.
procedure: make-accessor [name]
Return a new accessor with name (car name). If unspecified, name defaults to #f.
ensure-accessor calls make with metaclass <generic-with-setter>, as well as calls to ensure-generic, make-accessor and (tail recursively) ensure-accessor.
make-accessor calls make twice, first with metaclass <generic> to create a generic function for the setter, then with metaclass <generic-with-setter> to create the accessor, passing the setter generic function as the value of the #:setter keyword.