https://github.com/alex-gutev/generic-cl
Generic function interface to standard Common Lisp functions
https://github.com/alex-gutev/generic-cl
Last synced: 3 months ago
JSON representation
Generic function interface to standard Common Lisp functions
- Host: GitHub
- URL: https://github.com/alex-gutev/generic-cl
- Owner: alex-gutev
- License: mit
- Created: 2018-12-01T17:30:33.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-11-15T13:01:32.000Z (over 1 year ago)
- Last Synced: 2025-12-09T13:51:15.144Z (4 months ago)
- Language: Common Lisp
- Homepage: https://alex-gutev.github.io/generic-cl/
- Size: 646 KB
- Stars: 157
- Watchers: 14
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- curated-awesome-cl - generic-cl - Generic function interface to standard Common Lisp functions (equality, comparison, arithmetic, objects, iterator, sequences,…). [MIT][200]. See also the more lightweight [generic-comparability](https://github.com/pnathan/generic-comparability). [LLGPL][8]. (Python ##)
- awesome-cl - generic-cl - Generic function interface to standard Common Lisp functions (equality, comparison, arithmetic, objects, iterator, sequences,…). [MIT][200]. (Miscellaneous ##)
README
# GENERIC-CL
GENERIC-CL provides a generic function wrapper over various functions
in the Common Lisp standard, such as equality predicates and sequence
operations. The goal of this wrapper is to provide a standard
interface to common operations, such as testing for the equality of
two objects, which is extensible to user-defined types.
## Example
In Common lisp you have a number of different equality comparison
functions for different object types. Worse still you have to invent a
new name for the comparison functions for each of your own object
types.
**Standard Common Lisp:**
```lisp
(eq 'a x) ;; Symbols
(= 1 2) ;; Numbers
(equal '(1 2 3) x) ;; Lists
(equal "hello" y) ;; Strings
(equalp #(1 2 3) z) ;; Arrays
(foo-equal x y) ;; Instances of class foo
```
In GENERIC-CL there is a single equality predicate `=` which can be
used on objects of any builtin type. Since it's implemented using
generic functions, it can be extended with methods for user-defined
classes and structures.
**Using GENERIC-CL:**
```lisp
(= 'a x) ;; Symbols
(= 1 2) ;; Numbers
(= '(1 2 3) x) ;; Lists
(= "hello" y) ;; Strings
(= #(1 2 3) z) ;; Arrays
(= x y) ;; Instances of class foo
```
GENERIC-CL also provides generic interfaces for comparison (`<`, `>`,
...) functions, copying objects, iteration, sequence operations,
hash-tables capable of storing keys of user defined classes, and many
more.
## Documentation
Full documentation is available online in HTML format at
, and also in AsciiDoc
format in the `doc/` folder.
## Isn't this slow?
Generic functions do carry an additional overhead over ordinary
functions, however this isn't a significant issue for most
applications.
For those applications where the speed of generic-functions is an
issue, generic function calls can be optimized, using
[static-dispatch](https://github.com/alex-gutev/static-dispatch) on
which this library is built, to be as efficient (and sometimes even
more efficient) as ordinary function calls, when the types of the
arguments are known at compile-time. Check out the
[Optimization](https://alex-gutev.github.io/generic-cl/#gf-optimization)
section for more information.