This is the make-hash Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 06:58:27 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
Files are sorted by type and then listed depth-first from the systems components trees.
make-hash/make-hash.lisp
package.lisp
(file).
make-hash
(system).
*hash-factory-defaults*
(special variable).
define-hash-factory
(macro).
hash-initializer-default-format
(generic function).
initialize-hash
(generic function).
install-hash-reader
(macro).
make-hash
(function).
make-hash-error
(condition).
make-hash-factory
(function).
make-hash-transformer
(function).
*numbered-dispatch-defaults*
(special variable).
bag-seq-to-hash
(macro).
install-hash-delimited-reader
(function).
install-hash-dispatch-reader
(function).
make-hash-error-data
(reader method).
make-hash-error-text
(reader method).
numeric-dispatch-bounds-error
(condition).
read-close-delimiter
(function).
set-transformed-entry
(macro).
unknown-default-initializer
(condition).
unknown-initialization-pattern
(condition).
unmatched-closing-delimiter
(condition).
Packages are listed by definition order.
make-hash
common-lisp
.
*hash-factory-defaults*
(special variable).
define-hash-factory
(macro).
hash-initializer-default-format
(generic function).
initialize-hash
(generic function).
install-hash-reader
(macro).
make-hash
(function).
make-hash-error
(condition).
make-hash-factory
(function).
make-hash-transformer
(function).
*numbered-dispatch-defaults*
(special variable).
bag-seq-to-hash
(macro).
install-hash-delimited-reader
(function).
install-hash-dispatch-reader
(function).
make-hash-error-data
(generic reader).
make-hash-error-text
(generic reader).
numeric-dispatch-bounds-error
(condition).
read-close-delimiter
(function).
set-transformed-entry
(macro).
unknown-default-initializer
(condition).
unknown-initialization-pattern
(condition).
unmatched-closing-delimiter
(condition).
Definitions are sorted by export status, category, package, and then by lexicographic order.
Hash table creation options used as defaults by hash factory constructors.
These option specifications are passed last to make-hash by the hash
factories and so are overridden by options passed as explicit arguments
to the factory constructor.
Changing this variable affects the options used by every hash factory
that does not fully specify its options. This includes default calls to
the reader constructors. Of particular note are the :test
and :init-format options.
Create a hash-table factory NAME that calls ‘make-hash’ with HASH-OPTIONS. The resulting function packages its arguments as a list, which it passes as the :initial-contents argument to ‘make-hash’. The HASH-OPTIONS are alternating keywords and values that are passed as additional keyword arguments to ‘make-hash’, followed by – and thus overriding – the options in ‘*hash-factory-defaults*’. This is intended to allow one to use short names or customized policies in simple calling patterns. Complex initialization patterns may need the full power of ‘make-hash’ itself.
Creates a hash table factory specified by OPTIONS and installs it in
READTABLE (the current readtable by default). To have effect, this
must be called at toplevel.
OPTIONS is either a list of keyword-value pairs (as would be passed to
‘make-hash’ or ‘make-hash-factory’) or a hash factory function.
READTABLE is a readtable object, ‘*readtable*’ by default.
The keyword arguments control how the reader is modified as follows:
+ USE-DISPATCH (t by default) determines whether the reader macro uses a
dispatch character DISPATCH-CHAR before OPEN-CHAR. If non-nil, a
dispatch character is used and is registered in READTABLE. If this is
nil, then OPEN-CHAR and CLOSE-CHAR will be a raw delimited construct.
+ ALLOW-NUMBERED-DISPATCH (nil by default) allows a dispatched reader
macro to modify its hash test when given numeric arguments between
DISPATCH-CHAR and OPEN-CHAR. This only applies when USE-DISPATCH is
non-nil and when OPTIONS is a list, not a factory function. The goal
here is to make it easy to reuse reader factories in several contexts.
If nil, numbered dispatch is not supported. If t, numeric arguments
0, 1, 2, and 3 correspond to hash tests ‘eq’, ‘eql’, ‘equal’, and
‘equalp’ respectively. If a sequence of symbols or functions,
those functions are used for the hash test given a numeric
argument from 0 below the length of the sequence. In either case,
dispatch without a numeric argument uses the originally specified
options.
Note: This is an experimental feature and may be discontinued in
future versions if it proves more confusing than helpful.
+ OPEN-CHAR (default open-brace) is the character that delimits the
beginning of the hash-table contents. If USE-DISPATCH is non-nil,
this character must be preceeded by DISPATCH-CHAR, and optionally
a numeric argument.
+ CLOSE-CHAR (default close-brace) is the character that delimits
the end of the hash-table contents.
+ DISPATCH-CHAR (default #) is the character used to indicate a dispatched reader macro. When (and only when) USE-DISPATCH is non-nil. READTABLE is modified to register this as as a dispatch and a non-terminating macro character via ‘make-dispatch-macro=character’. Note that there can be more than one dispatch character in a read table.
Create, initialize, and return a new hash table.
Keyword options include all those of the standard ‘make-hash-table’, any
extension options allowed by the given implementation, and the following
four additional keyword arguments to control initialization. Users can
support other types/configurations (or alter the default handling) by
extending the generic function ‘initialize-hash’ in this package.
:INITIAL-CONTENTS object
If the supplied object is non-nil, the object is used to initialize
the created hash table in accordance with the INIT-FORMAT argument.
For some formats, the INIT-DATA argument may also be needed to
supply supplementary information for the initializer. The built-in
formats support the cases where object is either a hash table or
sequence from which the keys and values can be extracted. See the
table below for a detailed description of the possibilities.
:INIT-FORMAT keyword
A keyword specifying the structure of the initialization contents
and auxilliary data given by the INITIAL-CONTENTS and INIT-DATA
arguments. Built-in support is provided for :hash, :flat, :pairs,
:lists, :vectors, :seqs, :keys, :keychain, :keybag, and :function.
These are described in detail below. When an initializer format is
not supplied, it is computed by calling the generic function
‘hash-initializer-default-format’ on the given INITIAL-CONTENTS
object. A methods for this function should be defined whenever the
function ‘initialize-hash’ is extended to handle a new class of
INITIAL-CONTENTS objects. Methods can be overridden to change the
default used in existing cases.
:INIT-DATA object
Auxilliary data used for initialization. Its structure and meaning
depends on the value of INIT-FORMAT; see below for details.
:INIT-DEFAULT value
Default value to use in indirect initialization when the value for
the given key cannot be determined from the INITIAL-CONTENTS and
INIT-DATA for the particular INIT-FORMAT supplied.
Note that in cases where INITIAL-CONTENTS or INIT-DATA is a function,
that function should return three values. The primary value is the
key to set in the hash table; the secondary value is the value associated
with that key; and the optional ternary value is an indicator of whether
the key’s value or entry should be used. For the latter, ‘nil’ means that
the returned key and value should be stored in the table; ‘t’ means that
the entry should be *skipped*; and any other non-nil value means that
the key should be used with the supplied default value.
For the built-in initialization methods, such functions are used in three
ways: entry transformation – taking a key and value as arguments, key
mapping – taking just a key as argument, and entry generation – taking
arbitrary &rest arguments and returning nil when iteration should stop.
See below for more detail.
The following table describes the built-in initialization formats and
how the INITIAL-CONTENTS and INIT-DATA arguments are interpreted.
Either vectors or lists can be used interchangeably for passing sequences
to the latter arguments, except when data is an alist with :keys and a
list of arguments with :function. But in those latter cases, the user
can coerce a vector to list first if necessary.
Format Contents Data Description
——— ——– —- ———–
:hash hash-table null Shallow copy of given hash table with
shared structure in keys and values.
function Entry transformation of given hash table,
shared structure is possible.
:flat list or null List or vector of alternating keys and values
vector (key1 val1 ...) or #(key1 val1 ...),
in the style of a plist.
function Entry transformation of supplied
keys and values via given function
:pairs list or null List or vector of (key . value) cons pairs,
vector ((key1 . val1) ...) or #((key1 . val1)...).
function Entry transformation of supplied
key-value pairs via given function
:lists list or null List or vector of (key value) lists,
vector with only the first two elements of each used
function Entry transformation of supplied
keys and values via given function
:vectors list or null List or vector of #(key value) vectors,
vector with only the first two elements of each used
function Entry transformation of supplied
keys and values via given function
:seqs list or null List or vector of [key value] sequences,
vector with each sequence either a list or vector
and only the first two elements of each used
function Entry transformation of supplied
keys and values via given function
:keys list or hash-table Contents is a list or vector of keys that
vector are looked up in the hash-table data. These
key-value pairs are used for initialization,
with keys that are not found associated with
the given default.
list or list Contents is a list or vector of keys that
vector are looked up in the alist data. These
key-value pairs are used for initialization,
with keys that are not found associated with
the given default.
list or function Contents is a list or vector of keys that
vector are passed to the function data for key
mapping. The resulting key-value pairs
(allowing skips or defaults via bad-value)
are used for initialization.
:keychain list or list or Contents is a list or vector of keys, and vector vector data is a parallel list or vector of values given *in the same order*. Corresponding key-value pairs are used in initialization.
:keybag list or null Contents is a bag/multiset represented
vector as a list or vector. The hash table is
initialized to associate each unique key
to its count in the multiset.
list or vector Contents is a bag/multiset represented
vector as a list or vector. Data is a vector to
be indexed by the counts of each key.
Hash table is initialized to associate
each key to the value in data at index
equal to that key’s count. Counts outside
the bounds of data are associated to
the default value.
list or hash-table Contents is a bag/multiset represented
vector as a list or vector. Data is a hash-table
with positive integer keys representing a
sparse vector. Hash table is initialized to
associate each key to the value in data that
is associated with that key’s count. Counts
not in data are associated to the default
value.
list or function Contents is a bag/multiset represented
vector as a list or vector. Data is a function
of two arguments KEY and COUNT, the latter
a positive integer. Table is initialized to
associate each key to the value returned
by data on that key and its count. Data
satisfies the bad-value convention described
earlier.
:function function list or Contents is a function that is applied to null the values in the list data. Hash table is initialized by entry generation until the function returns a nil primary value.
Create anonymous hash-table factory that calls ‘make-hash’ with HASH-OPTIONS. The resulting function packages its arguments as a list, which it passes as the :initial-contents argument to ‘make-hash’. The HASH-OPTIONS are alternating keywords and values that are passed as additional keyword arguments to ‘make-hash’, followed by – and thus overriding – the options in ‘*hash-factory-defaults*’. This is intended to allow one to use short names or customized policies in simple calling patterns. Complex initialization patterns may need the full power of ‘make-hash’ itself.
Transform function on DOMAIN, F, to be suitable for use with ‘make-hash’.
DOMAIN is one of the keywords :key, :value, or :entry. F is a function
that takes a key, a value, or a key and a value, respectively. BADP is a
function with the same argument signature that returns a ternary value:
nil means that the transformed entry should be used as is, t means that
the entry should be skipped, and any other non-nil value means that the
key should be used with a default. Note that if BADP returns a non-nil
value, then F is *not* called for that entry.
The returned function accepts a key and a value (the value is optional with DOMAIN :key) and returns three values: the key, the value, and the bad-value ternary for that entry. This has a signature appropriate for passing as the :initial-contents or :init-data arguments to ‘make-hash’ when the format expects/allows a function in those slots.
Select an initializer format based on the given initial contents SOURCE.
function
)) ¶vector
)) ¶list
)) ¶hash-table
)) ¶Create and add entry to TABLE using info of format FORM in SOURCE and DATA.
SOURCE contains the main contents, and DATA contains auxilliary
information or objects required for initialization. DEFAULT is the value
that should be stored in the table when an appropriate value associated
to a key cannot be found. See ‘make-hash’ for details on configurations
with predefined support. Adding or redefining methods for this function
allows extension or modification of the initialization mechanism.
Note the convention, used by the predefined methods, that functions
passed as either SOURCE or DATA are expected to return three values
KEY VALUE [BAD-VALUE]
that are used (under certain conditions) to create a new entry KEY . VALUE in the TABLE to be initialized. Here, BAD-VALUE is a *ternary* value: nil means to use KEY and VALUE as is; t means to skip creating this entry; and any other non-nil object means to associate to KEY the specified DEFAULT instead of VALUE.
hash-table
) (form (eql :function)
) (source function
) (data list
) default) ¶SOURCE is a function returning entries in TABLE until primary value is nil. DATA is a list of arguments, possibly null, passed to the function each call.
hash-table
) (form (eql :keybag)
) (source vector
) (data function
) default) ¶SOURCE is a vector of keys, DATA maps keys and counts to entries stored in TABLE.
hash-table
) (form (eql :keybag)
) (source list
) (data function
) default) ¶SOURCE is a vector of keys, DATA maps keys and counts to entries stored in TABLE.
hash-table
) (form (eql :keybag)
) (source vector
) (data hash-table
) default) ¶SOURCE is a list of keys, value in DATA for key’s count is key’s value. If count is not in DATA table, DEFAULT is used instead.
hash-table
) (form (eql :keybag)
) (source list
) (data hash-table
) default) ¶SOURCE is a list of keys, value in DATA for key’s count is key’s value. If count is not in DATA table, DEFAULT is used instead.
hash-table
) (form (eql :keybag)
) (source vector
) (data vector
) default) ¶SOURCE is a vector of keys, element of DATA at index of key’s count is key’s value. If count is >= length of DATA vector, DEFAULT is used instead.
hash-table
) (form (eql :keybag)
) (source list
) (data vector
) default) ¶SOURCE is a list of keys, element of DATA at index of key’s count is key’s value. If count is >= length of DATA vector, DEFAULT is used instead.
hash-table
) (form (eql :keybag)
) (source vector
) (data null
) default) ¶SOURCE is a vector of keys as a bag/multiset, counts stored in TABLE for each key. DEFAULT is ignored.
hash-table
) (form (eql :keybag)
) (source list
) (data null
) default) ¶SOURCE is a list of keys as a bag/multiset, counts stored in TABLE for each key. DEFAULT is ignored.
hash-table
) (form (eql :keychain)
) (source vector
) (data vector
) default) ¶SOURCE is a vector of keys, DATA a parallel vector of values; pairs stored in TABLE. If SOURCE is longer than DATA, additional entries have value DEFAULT.
hash-table
) (form (eql :keychain)
) (source list
) (data vector
) default) ¶SOURCE is a list of keys, DATA is a parallel vector of values; pairs stored in TABLE. If SOURCE is longer than DATA, additional entries use DEFAULT for their value.
hash-table
) (form (eql :keychain)
) (source vector
) (data list
) default) ¶SOURCE is a vector of keys, DATA is a parallel list of values; pairs stored in TABLE. If SOURCE is longer than DATA, additional entries use DEFAULT for their value.
hash-table
) (form (eql :keychain)
) (source list
) (data list
) default) ¶SOURCE is a list of keys, DATA is a parallel list of values; pairs stored in TABLE. If SOURCE is longer than DATA, additional entries use DEFAULT for their value.
hash-table
) (form (eql :keys)
) (source vector
) (data function
) default) ¶SOURCE is a vector of keys, DATA is an function mapping keys to entries stored in TABLE.
hash-table
) (form (eql :keys)
) (source vector
) (data list
) default) ¶SOURCE is a vector of keys, DATA is an alist whose corresponding entries are stored in TABLE.
hash-table
) (form (eql :keys)
) (source vector
) (data hash-table
) default) ¶SOURCE is a vector of keys, DATA is a hash table whose corresponding entries are stored in TABLE.
hash-table
) (form (eql :keys)
) (source list
) (data function
) default) ¶SOURCE is a list of keys, DATA is an function mapping keys to entries stored in TABLE.
hash-table
) (form (eql :keys)
) (source list
) (data list
) default) ¶SOURCE is a list of keys, DATA is an alist whose corresponding entries are stored in TABLE.
hash-table
) (form (eql :keys)
) (source list
) (data hash-table
) default) ¶SOURCE is a list of keys, DATA is a hash table whose corresponding entries are stored in TABLE.
hash-table
) (form (eql :seqs)
) (source vector
) (data function
) default) ¶SOURCE is a vector of sequences of the form (key val ...), and each key-val pair is transformed by DATA and entered into TABLE.
hash-table
) (form (eql :seqs)
) (source vector
) (data null
) default) ¶SOURCE is a vector of sequences of the form (key val ...), and each key-val pair is transformed by DATA then entered into TABLE.
hash-table
) (form (eql :seqs)
) (source list
) (data function
) default) ¶SOURCE is a list of sequences of the form [key val ...], and each key-val pair is transformed by DATA and entered into TABLE.
hash-table
) (form (eql :seqs)
) (source list
) (data null
) default) ¶SOURCE is a list of sequences of the form (key val ...), and each key-val pair is entered into TABLE.
hash-table
) (form (eql :vectors)
) (source vector
) (data function
) default) ¶SOURCE is a vector of lists of the form (key val ...), and each key-val pair is transformed by DATA and entered into TABLE.
hash-table
) (form (eql :vectors)
) (source vector
) (data null
) default) ¶SOURCE is a vector of lists of the form (key val ...), and each key-val pair is transformed by DATA then entered into TABLE.
hash-table
) (form (eql :vectors)
) (source list
) (data function
) default) ¶SOURCE is a list of vectors of the form [key val ...], and each key-val pair is transformed by DATA and entered into TABLE.
hash-table
) (form (eql :vectors)
) (source list
) (data null
) default) ¶SOURCE is a list of lists of the form (key val ...), and each key-val pair is entered into TABLE.
hash-table
) (form (eql :lists)
) (source vector
) (data function
) default) ¶SOURCE is a vector of lists of the form (key val ...), and each key-val pair is transformed by DATA and entered into TABLE.
hash-table
) (form (eql :lists)
) (source vector
) (data null
) default) ¶SOURCE is a vector of lists of the form (key val ...), and each key-val pair is transformed by DATA then entered into TABLE.
hash-table
) (form (eql :lists)
) (source list
) (data function
) default) ¶SOURCE is a list of lists of the form (key val ...), and each key-val pair is transformed by DATA and entered into TABLE.
hash-table
) (form (eql :lists)
) (source list
) (data null
) default) ¶SOURCE is a list of lists of the form (key val ...), and each key-val pair is entered into TABLE.
hash-table
) (form (eql :pairs)
) (source vector
) (data function
) default) ¶SOURCE is a vector of (key . value) pairs that are transformed by function DATA and entered into TABLE.
hash-table
) (form (eql :pairs)
) (source vector
) (data null
) default) ¶SOURCE is a vector of (key . value) cons pairs that are entered into TABLE.
hash-table
) (form (eql :pairs)
) (source list
) (data function
) default) ¶SOURCE is an alist whose key-value pairs are transformed by function DATA and entered into TABLE.
hash-table
) (form (eql :pairs)
) (source list
) (data null
) default) ¶SOURCE is an alist whose key-value pairs are entered into TABLE.
hash-table
) (form (eql :flat)
) (source vector
) (data function
) default) ¶SOURCE is a vector of alternating key-value pairs that are transformed by the function DATA and entered into TABLE.
hash-table
) (form (eql :flat)
) (source vector
) (data null
) default) ¶SOURCE is a vector of alternating key-value pairs that are entered into TABLE.
hash-table
) (form (eql :flat)
) (source list
) (data function
) default) ¶SOURCE is a list of alternating key-value pairs that are transformed by the function DATA and entered into TABLE.
hash-table
) (form (eql :flat)
) (source list
) (data null
) default) ¶SOURCE is a list of alternating key-value pairs that are entered into TABLE.
hash-table
) (form (eql :hash)
) (source hash-table
) (data function
) default) ¶Make TABLE a transformed copy of SOURCE by function DATA, possibly sharing structure.
hash-table
) (form (eql :hash)
) (source hash-table
) (data null
) default) ¶Make TABLE a shallow copy of SOURCE with shared key and value structure.
Fallback initialization of unsupported configurations.
Error encountered during hash table creation or initialization.
Hash table tests used by dispatch reader macros with numeric arguments. A numeric argument of n to the reader macro uses the test at index n, but an index longer than the length of this sequence raises an error.
Convert a sequence representation of a bag/multiset to a hash table.
SEQ is a sequence of type SEQTYPE, a symbol, either list or vector explicitly.
Its entries are elements of the base set, possibly with repetitions.
HASH is a hash table. Upon return, its keys are the elements of the base
set, and its values are the repetition counts for each element.
Create a new hash table entry from a given entry and transform protocol.
ENTRY0 specifies the information to which the transform is apply’d.
DEFAULT is a default value to use for entry if the transform indicates
so. TRANSFORM is a function that accepts arguments in the entry (e.g., a
key value pair) and returns three values a KEY, a VALUE, and a BAD-VALUE
ternary indicator, with the last of these optional. If BAD-VALUE is nil,
KEY and VALUE will be entered in TABLE; if BAD-VALUE is t, the entry is
skipped; and BAD-VALUE is otherwise non-nil, KEY and DEFAULT are entered
into TABLE. TABLE is the hash table to modify.
If ON is supplied (it’s value does not matter), then the function
CONDITION is called on the KEY returned by TRANSFORM, and the form DO is
executed if this returns a non-nil value. This occurs *before* the
BAD-VALUE is checked or the key assigned.
VIA and INTO are syntactic placeholders whose values are ignored.
make-hash-error
)) ¶data
.
make-hash-error
)) ¶text
.
A numeric argument to a dispatch reader macro is out of bounds.
Attempt to make-hash without :init-format when no
default initialization is defined for the given initial-contents.
Attempt to initialize-hash with an unrecognized pattern of argument specialization or unrecognized format.
Reader can find no closing delimiter for literal hash table.
Jump to: | B D F G H I M R S |
---|
Jump to: | B D F G H I M R S |
---|
Jump to: | *
D S T |
---|
Jump to: | *
D S T |
---|
Jump to: | C F M N P S U |
---|
Jump to: | C F M N P S U |
---|