The fare-memoization Reference Manual

This is the fare-memoization Reference Manual, version 1.2.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 06:04:53 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 fare-memoization

memoizing functions the correct, portable way

Author

Francois-Rene Rideau

License

MIT

Long Description

define memoized functions and memoize previously defined functions

Version

1.2.0

Source

fare-memoization.asd.

Child Component

memoization.lisp (file).


3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 fare-memoization/fare-memoization.asd

Source

fare-memoization.asd.

Parent Component

fare-memoization (system).

ASDF Systems

fare-memoization.


3.1.2 fare-memoization/memoization.lisp

Source

fare-memoization.asd.

Parent Component

fare-memoization (system).

Packages

fare-memoization.

Public Interface
Internals

4 Packages

Packages are listed by definition order.


4.1 fare-memoization

Source

memoization.lisp.

Nickname

fmemo

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Special variables

Special Variable: *memoized*
Package

fare-memoization.

Source

memoization.lisp.


5.1.2 Macros

Macro: define-memo-function (name formals &body body)

Like defun, but creates a memoized function.
Also, if the name is a CONS, then the first element is the name, and the rest is a list of keyword arguments, TABLE and NORMALIZATION as per MEMOIZE.

Package

fare-memoization.

Source

memoization.lisp.


5.1.3 Ordinary functions

Function: memoize (symbol &rest keys &key table argument-normalizer call-normalizer normalization)

Memoize the function associated to given SYMBOL.

Beware that unless the function was declared NOTINLINE, callers may have inlined the original definition and will not see the memoized function.
Moreover, if the function is self-recursive,
this declaration must have happened before it was defined.

Keyword argument TABLE (default: a fresh EQUAL hash-table) lets you
specify an existing hash-table for the memoized computations;
it may have been created with appropriate options regarding equality predicate and weak pointers, initial contents, etc., and you may clear it when needed.

Keyword argument ARGUMENT-NORMALIZER (default: NIL) lets you specify a function taking a list of arguments and returning a normalized list of arguments,
so that all lists with the same normalization will share the same memoized computation. NIL means no such normalization, which is the same as #’LIST.

Keyword argument CALL-NORMALIZER (alias: NORMALIZATION, default: NIL)
lets you specify a function taking a continuation and the function arguments, e.g. with lambda-list (CONTINUATION &REST ARGUMENTS)
which may transform the argument list before to call the continuation
with a normalized argument list that will be used to query the computation cache and invoke the actual computation function; NIL means no such transformation, which has the same effect as specifying #’APPLY as a transformation.

If the function was already being memoized, any previous memoization arguments, i.e. TABLE and ARGUMENT-NORMALIZER, is replaced with the newly specified values (unspecified arguments are replaced by defaults rather than left as previously specified).

Package

fare-memoization.

Source

memoization.lisp.

Function: memoized-apply (function &rest arguments)
Package

fare-memoization.

Source

memoization.lisp.

Function: memoized-funcall (&rest arguments)
Package

fare-memoization.

Source

memoization.lisp.

Function: memoizing (function &rest keys &key table normalization)

Given a function, return a memoizing version of same function. Keyword arguments TABLE and NORMALIZATION are as per MEMOIZE.

Package

fare-memoization.

Source

memoization.lisp.

Function: unmemoize (symbol)

undoing the memoizing function, return the memoization-info record for the function

Package

fare-memoization.

Source

memoization.lisp.

Function: unmemoize-1 (symbol &rest arguments)

Forget the memoized result of calling SYMBOL with arguments ARGUMENTS. Do not forget memoized results of calling the function with other arguments. Returns T if a stored result was found and removed, NIL otherwise.

Package

fare-memoization.

Source

memoization.lisp.


5.2 Internals


5.2.1 Ordinary functions

Function: compute-memoized-function (info arguments)

the basic helper for computing with a memoized function described by INFO, being called with arguments ARGUMENTS

Package

fare-memoization.

Source

memoization.lisp.

Function: make-memoization-info (function &rest keys &key table argument-normalizer call-normalizer normalization)
Package

fare-memoization.

Source

memoization.lisp.

Function: memoization-wrapper (info)

the basic helper for computing with a memoized function described by INFO, being called with arguments ARGUMENTS

Package

fare-memoization.

Source

memoization.lisp.


5.2.2 Generic functions

Generic Reader: memoized-argument-normalizer (object)
Package

fare-memoization.

Methods
Reader Method: memoized-argument-normalizer ((memoization-info memoization-info))

either NIL or a function to normalize arguments before memoization

Source

memoization.lisp.

Target Slot

argument-normalizer.

Generic Reader: memoized-call-normalizer (object)
Package

fare-memoization.

Methods
Reader Method: memoized-call-normalizer ((memoization-info memoization-info))

either NIL or a function to normalize arguments before memoization

Source

memoization.lisp.

Target Slot

call-normalizer.

Generic Reader: memoized-table (object)
Package

fare-memoization.

Methods
Reader Method: memoized-table ((memoization-info memoization-info))

a hash-table containing the memoized computations so far

Source

memoization.lisp.

Target Slot

table.

Generic Reader: original-function (object)
Package

fare-memoization.

Methods
Reader Method: original-function ((memoization-info memoization-info))

The original, unmemoized, function

Source

memoization.lisp.

Target Slot

function.

Generic Reader: wrapped-function (object)
Generic Writer: (setf wrapped-function) (object)
Package

fare-memoization.

Methods
Reader Method: wrapped-function ((memoization-info memoization-info))
Writer Method: (setf wrapped-function) ((memoization-info memoization-info))

The memoizing version of the function.

Source

memoization.lisp.

Target Slot

wrapped-function.


5.2.3 Classes

Class: memoization-info

information about a function that was memoized

Package

fare-memoization.

Source

memoization.lisp.

Direct methods
Direct slots
Slot: function

The original, unmemoized, function

Package

common-lisp.

Initargs

:function

Readers

original-function.

Writers

This slot is read-only.

Slot: wrapped-function

The memoizing version of the function.

Readers

wrapped-function.

Writers

(setf wrapped-function).

Slot: table

a hash-table containing the memoized computations so far

Initform

(make-hash-table :test (quote equal))

Initargs

:table

Readers

memoized-table.

Writers

This slot is read-only.

Slot: argument-normalizer

either NIL or a function to normalize arguments before memoization

Initargs

:argument-normalizer

Readers

memoized-argument-normalizer.

Writers

This slot is read-only.

Slot: call-normalizer

either NIL or a function to normalize arguments before memoization

Initargs

:normalization, :call-normalizer

Readers

memoized-call-normalizer.

Writers

This slot is read-only.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   (  
C   D   F   G   M   O   U   W  
Index Entry  Section

(
(setf wrapped-function): Private generic functions
(setf wrapped-function): Private generic functions

C
compute-memoized-function: Private ordinary functions

D
define-memo-function: Public macros

F
Function, compute-memoized-function: Private ordinary functions
Function, make-memoization-info: Private ordinary functions
Function, memoization-wrapper: Private ordinary functions
Function, memoize: Public ordinary functions
Function, memoized-apply: Public ordinary functions
Function, memoized-funcall: Public ordinary functions
Function, memoizing: Public ordinary functions
Function, unmemoize: Public ordinary functions
Function, unmemoize-1: Public ordinary functions

G
Generic Function, (setf wrapped-function): Private generic functions
Generic Function, memoized-argument-normalizer: Private generic functions
Generic Function, memoized-call-normalizer: Private generic functions
Generic Function, memoized-table: Private generic functions
Generic Function, original-function: Private generic functions
Generic Function, wrapped-function: Private generic functions

M
Macro, define-memo-function: Public macros
make-memoization-info: Private ordinary functions
memoization-wrapper: Private ordinary functions
memoize: Public ordinary functions
memoized-apply: Public ordinary functions
memoized-argument-normalizer: Private generic functions
memoized-argument-normalizer: Private generic functions
memoized-call-normalizer: Private generic functions
memoized-call-normalizer: Private generic functions
memoized-funcall: Public ordinary functions
memoized-table: Private generic functions
memoized-table: Private generic functions
memoizing: Public ordinary functions
Method, (setf wrapped-function): Private generic functions
Method, memoized-argument-normalizer: Private generic functions
Method, memoized-call-normalizer: Private generic functions
Method, memoized-table: Private generic functions
Method, original-function: Private generic functions
Method, wrapped-function: Private generic functions

O
original-function: Private generic functions
original-function: Private generic functions

U
unmemoize: Public ordinary functions
unmemoize-1: Public ordinary functions

W
wrapped-function: Private generic functions
wrapped-function: Private generic functions