Inspired by generic-cl and polymorphic-functions, this library reimplements standard library functions (and adds some more) based on type dispatch. Supports user defined specializations as well. It also tries to be as strictly typed as possible, resulting in compile-time errors/warnings in case types are mismatched. However, there are ways to relax the restrictions in places where it would make sense (such as different numeric types comparison).
It may look like the whole thing consists of too many systems that are too small, but that is intentional. The main idea is, even if some users disagree with the overall design, they can still use small parts. It is also easier to debug and maintain several small systems rather than a single big one.
It currently works anywhere polymorphic-functions work. Cltl2 support is the most important thing.
For more detailed documentaion, look at the specific system README.
This system's sole purpose is to load (and test) all other systems that I consider working. If you want to use full power of lisp-polymorph, use this system.
Ad hoc polymorphic:
+
,-
,*
,/
are arithmetic functionsincf
,decf
,multf
,divf
are updating macros corresponding to the functions above=
,/=
are equality functions>
,>=
,<
,<=
are inequality functions
Parametric polymorphic:
min
andmax
are based on<
and>
(currently any kind of parametric polymorphism is just a convention).
Ad hoc polymorphic:
cast
function is similar tocoerce
. WIP.copy
currently has two versions:deep-copy
andshallow-copy
Warning, these will probably be refactored to have ad-hoc copy
and parametric deep
/shallow
versions.
Accessors to different properties.
Ad hoc polymorphic:
at/at-safe
functions is an extended version ofelt/gethash
. Are SETFable.front/front-safe/back/back-safe
are the first and last elements of the container whenever that makes sense. Are SETFable.emptyp
,size
,capacity
deal with container sizes.
Biggest system so far. WIP. Implements:
- Standard traversing functions (map/reduce/find/etc). WIP.
- Iterator protocol and mirrors of the standard traversing functions that return iterators.
- (TODO) Extensions for iterate (since we already depend on it).
- (TODO) Maybe somehow base it on series?
While there are currently no "polymorphic" macros, these macros are useful for the style of development this system suggests.
zapf
is for updating values value in place using its previous value. It is a generalization of macros likeincf
ordecf
.setf*
is for updating values in a manner similar tosetf
but in a type safe way. Can be annoying at times due to imperfections of type inference.bind/bind*
unites 3 things:let/let*
,multiple-value-bind
, and builtin type declarations. Usesdefault
for filling out the values if type was provided, otherwise defaults tonil
.def
is a simplification ofdefstruct
that fills in default values usingdefault
and given types. It has accessors for slots defined via defpolymorph and is unable to do inheritance -- use composition. Very much alpha version, may change.
Utility functions (like default
) and ctype processing. Uses ctype as a backend.
WIP. So far has at least maps (RB tree based), deques (array based), priority-queues, double linked lists. I am planning to replicates standard structures as well, including vectors, single-linked lists and hashmaps/sets.
WIP. Currently broken. Allows for customization of funcall
and apply
.
Tests are distributed throughout the system. Run (asdf:test-system 'polymorph.stl)
.
Alex Gutev for inspiration and immense help with testing all the systems, as well as coauthoring polymorph.traversable/callable
.
Shubhamkar Ayare for providing the backend for this library. Without his efforts it would not be possible. His initial motivation for polymorphic-functions came from his library dense-arrays, check it out.