README.md

CL-CUSTOM-HASH-TABLE: Custom hash tables for Common Lisp

Introduction

CL-CUSTOM-HASH-TABLE allows creation and use of "custom hash tables".
Custom hash tables can use arbitrary TEST/HASH functions,
in addition to the TEST functions allowed by the standard
(EQ, EQL, EQUAL and EQUALP).

This library is primarily a compatibility layer, unifying how to create these hash table in different Lisp implementations. Furthermore this library provides a simple yet fully functional fall-back solution for implementations that don't support this functionality natively (yet).

License

Compatibility

This library does not shadow symbols in the COMMON-LISP package. It does require that all access to (potential) custom hash tables is lexical wrapped in a WITH-CUSTOM-HASH-TABLE form (see example below).

You can trace your test/hash functions to check they are really getting called later:

(trace foo-equal-p foo-hash)

Use WITH-CUSTOM-HASH-TABLE around access to the hash table.
This ensures functions GETHASH, REMHASH and MAPHASH do the right thing.
If you forget this, your code will not work in implementations
that don't support custom TEST/HASH functions natively!

Implementation details

Several Lisp implementations already support
custom TEST and HASH arguments for MAKE-HASH-TABLE.
This library is a small wrapper around the vendor-specific extensions.
(Allegro CL, CCL, CMUCL, LispWorks, SBCL)

In other Lisp implementations (ECL) a fall-back solution is used:

custom hash tables are created on top of standard hash tables;

the WITH-CUSTOM-HASH-TABLE code walker replaces GETHASH and friends by custom functions that work on both standard and "custom" hash tables.