1. fast-generic
    1. Introduction
    2. Documentation
      1. define-generic
      2. define-type
      3. any
    3. Restrictions
    4. More information
    5. Author
    6. License
    7. Version History

fast-generic

Introduction

Very efficient generic functions over arbitrary types.

Documentation

define-generic

[syntax] (define-generic (NAME ARGUMENT ...) BODY ...)

Defines a generic function with the given name, specialized to argument-types as described by ARGUMENT .... ARGUMENT should be either a symbol or a list of the form (TYPE SYMBOL) where a symbol is equivalent to (any SYMBOL).

Calls to NAME textually following this generic definition will be dispatched to the first registered generic with this name that matches the types of the arguments given in the procedure call.

define-type

[syntax] (define-type TYPENAME PREDICATE [BASETYPE])

Defines a named type for objects that satisfy PREDICATE (a procedure of one argument that returns either true or false). If BASETYPE is given, it designates the parent type of TYPENAME. Thus types may form a hierarchy. If BASETYPE is not given, any is assumed.

The predicate should be referentially transparent and not cause any side- effects.

any

 [type] any

The universal base type for objects that satisfy any?, that is, all objects.

Restrictions

More information

The author of the original implementation describes the implementation of an older version of this code in a paper that can be found here.

Some examples of using this egg can be found in The Chicken Gazette, Issue 14.

Author

Thant Tessman, ported to CHICKEN by felix

License

Copyright (c) Thant Tessman
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
conditions are met:
  Redistributions of source code must retain the above copyright notice, this list of conditions and the following
    disclaimer. 
  Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
    disclaimer in the documentation and/or other materials provided with the distribution. 
  Neither the name of the author nor the names of its contributors may be used to endorse or promote
    products derived from this software without specific prior written permission. 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

Version History

0.4
fixed broken result check and testcases
0.3
slight dispatch optimization; basetype argument to define-type wasn�t quoted
0.1
initial release