The serapeum Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The serapeum Reference Manual

This is the serapeum Reference Manual, generated automatically by Declt version 2.4 "Will Decker" on Wed Jun 20 12:33:38 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

Table of Contents

Overview

Build Status

Serapeum is a conservative library of Common Lisp utilities. It is a supplement, not a competitor, to Alexandria. That means it is safe to do:

(defpackage ... (:use #:cl #:alexandria #:serapeum),

without package conflicts.

There may already be too many utility libraries for Common Lisp. Releasing another has become something to apologize for, not celebrate. But I would rather make my apologies than have to maintain copy-pasted versions of the same utilities across a dozen systems. And, though Serapeum is justified even if only I ever use it, the best way to ensure its quality is to write it as if for general use.

Serapeum is conservative: its goal is to fill in gaps in Common Lisp, not to redesign it. But it is less conservative than Alexandria. Alexandria limits itself to utilities with a Common Lisp pedigree. Serapeum casts a wider net: other dialects of Lisp, and other languages in the functional and array families, have been drafted.

Alexandria is self-contained. It exists in splendid isolation, without depending on, or even acknowledging, other libraries. Serapeum tries to be a good citizen of the Quicklisp era: whenever possible, it avoids duplicating functionality that can be had elsewhere.

Many of the utilities in Serapeum are original; many are borrowed from other languages, or from other Lispers. I try to give credit in the docstrings, but sometimes I have forgotten where I got an idea or a name. I regard missing credits as bugs: please report them.

Serapeum is intended to be portable, but it is principally tested where it is developed, on SBCL and Clozure CL. (Automated tests are also run on [Allegro][].) Patches for other Lisps are always welcome, whether bug fixes or implementation-specific optimizations.

Commentary

One goal of Serapeum is to have excellent documentation. A utility library is a fork of its language; it deserves documentation of the same quality as a language reference. If a utility is not worth documenting, it is not worth having.

The full function reference will be found here. (It is in a separate file in deference to documentation browsers, which often print the README as a preamble to their own function reference).

Most utilities in Serapeum stand alone, but there are some families that deserve separate introduction.

Dividing sequences

All recent functional programming languages share a family of useful sequence-related functions with terrible names. All of them are called something like “split”, “divide”, or “group”, more or less at random.

For each function, we ensure:

The function that returns runs of like elements in a sequence is called runs:

(runs '(head tail head head tail))
=> '((head) (tail) (head head) (tail))

The function that returns a sequence in batches of a certain maximum size is called batches:

(batches (iota 11) 2)
=> ((0 1) (2 3) (4 5) (6 7) (8 9) (10))

The function which groups the like elements of a sequence is called assort (because it returns a sequence assorted by some property).

(assort (iota 10)
        :key (lambda (n) (mod n 3)))
=> '((0 3 6 9) (1 4 7) (2 5 8))

The function that takes a predicate and a sequence, and returns two sequences – one sequence of the elements for which the function returns true, and one sequence of the elements for which it returns false – is (still) called partition.

(partition #'oddp (iota 10))
=> (1 3 5 7 9), (0 2 4 6 8)

The generalized version of partition, which takes a number of functions and returns the items that satisfy each condition, is called partitions.

(partitions (list #'primep #'evenp) (iota 10))
=> ((2 3 5 7) (0 4 6 8)), (1 9)

Items that do not belong in any partition are returned as a second value.

Serapeum simply re-exports split-sequence, which seems to be firmly rooted under its present name.

Binding values in the function namespace

fbind, fbind*, fbindrec, and fbindrec* bind values in the function namespace.

fbind and fbindrec are like flet and labels, respectively.

(fbind ((fn (lambda ....))) ...)
≡ (flet ((fn ...)) ...)

(fbindrec ((fn (lambda ...))) ...)
≡ (labels ((fn ...)) ...)

fbind* and fbindrec* have no exact parallels: they bind functions in sequence, so that each can be used in the construction (not just the definition, as with fbindrec) of the next.

(fbind* ((flip2 (lambda (fn)
                 (lambda (x y)
                   (funcall fn y x))))
         (xcons (flip2 #'cons)))
  (xcons 2 1))
=> (1 . 2)

These are non-trivial implementations. In many cases, fbind can produce code that is more efficient than using funcall, and even eliminate the overhead of higher-order functions like compose and curry. And fbindrec, which builds on fbind, further implements the optimizing transformation from Waddell et. al., Fixing Letrec.

For binding values in the function namespace at the top level, Serapeum provides defalias:

(defalias xcons (flip #'cons))

This is equivalent to (setf (fdefinition ...)), but also gives the function a compile-time definition so compilers don’t complain about its being undefined.

Internal definitions

The local form lets you use top-level definition forms to create local bindings. You can use defun instead of labels, defmacro instead of macrolet, def (which is Serapeum’s macro for top-level lexical bindings) instead of let, and so forth.

This has three advantages:

  1. Given a set of variable, function, and macro bindings, you can leave it to the compiler to figure out how to nest them. (This could be because you are porting a function from a language that uses flat bindings, or just because you are writing a very complicated function.)

  2. You can use macro-defining macros (macros that expand into defmacro), as well as macros that expand into defun forms, to create local bindings.

  3. You can (using local* or block-compile) easily switch to block compilation of top-level functions.

Serapeum’s implementation of internal definitions is as complete as it can be while remaining portable. That means full support for variables, functions, and symbol macros, but restricted support for macros.

Example: macros that work locally and globally

For example, memoizing local functions is usually clumsy; given local you can define a single defmemo form that supports both defun and labels.

(defmacro defmemo (name params &body body)
  (with-gensyms (memo-table args result result?)
    `(let ((,memo-table (make-hash-table :test 'equal)))
       (defun ,name (&rest ,args)
         (multiple-value-bind (,result ,result?)
             (gethash ,args ,memo-table)
           (if ,result?
               ,result
               (setf (gethash ,args ,memo-table)
                     (apply (lambda ,params
                              ,@body)
                              ,args))))))))

At the top level, this expands into an example of “let over defun” (gensyms elided for readability):

;; This source form
(defmemo fibonacci (n)
    (if (<= n 1)
        1
        (+ (fibonacci (- n 1))
           (fibonacci (- n 2)))))
           
;; Expands into...
(let ((memo-table (make-hash-table :test 'equal)))
  (defun fibonacci (&rest args)
    (multiple-value-bind (result result?)
        (gethash args memo-table)
      (if result? result
          (setf (gethash args memo-table)
                (apply (lambda (n)
                         (if (<= n 1)
                             1
                             (+ (fibonacci (- n 1))
                                (fibonacci (- n 2)))))
                       args))))))

But within a local form, it expands differently. This nearly identical source form:

(local
  (defmemo fibonacci (n)
    (if (<= n 1)
        1
        (+ (fibonacci (- n 1))
           (fibonacci (- n 2)))))

  (fibonacci 100))

Expands into this very different code (simplified for readability):

(let (fn)
  (labels ((fibonacci (&rest args)
             (apply fn args)))
    (let ((memo-table (make-hash-table :test 'equal)))
      (setf fn
            (named-lambda fibonacci (&rest args)
              (multiple-value-bind (result result?)
                  (gethash args memo-table)
                (if result? result
                    (setf (gethash args memo-table)
                          (apply
                           (lambda (n)
                             (if (<= n 1) 1
                                 (+ (fibonacci (- n 1))
                                    (fibonacci (- n 2)))))
                           args))))))
      
      (fibonacci 100))))

Example: block compiling

The macro local* is almost the same as local, except that it leaves the last form in the body intact. This is useful for obtaining block compilation in Lisps that don’t have a syntax for it.

During development, you define functions at the top level inside a progn.

 (progn
   (defun aux-fn-1 ...)
   (defun aux-fn-2 ...)
   (defun entry-point ...))

Then, when you decide you want block compilation, simply switch the progn to a local*:

 (local*
   (defun aux-fn-1 ...)
   (defun aux-fn-2 ...)
   (defun entry-point ...))

Which expands into something like:

(labels ((aux-fn-2 ...)
         (aux-fn-1 ...))
  (defun entry-point ...))

This has the slight disadvantage that calls to the entry points, including self calls, will still be compiled as global calls. If you want calls to the entry points to be compiled as local calls, you can use the block-compile macro instead.

Using block-compile, you can write:

(block-compile (:entry-points (entry-point))
  (defun aux-fn-1 ...)
  (defun aux-fn-2 ...)
  (defun entry-point ...))

And have it expand into something like:

(labels ((aux-fn-2 ...)
     (aux-fn-1 ...)
     (entry-point ...))
  (defalias entry-point #'entry-point))

Compile-time exhaustiveness checking

etypecase-of is just like etypecase, except that it takes an additional argument – the type to be matched against – and warns, at compile time, if the clauses in its body are not an exhaustive partition of that type.

ecase-of is a succint variant of etypecase with the same syntax as ecase.

typecase-of and case-of are etypecase-of and ecase-of, respectively, except that they expect, and enforce, the presence of an otherwise clause.

There are also continuable versions of these macros – ctypecase-of and ccase-of.

Example: enums

We may call a type defined using member an enumeration. Take an enumeration like this:

(deftype switch-state ()
  '(member :on :off :stuck :broken))

Now we can use ecase-of to take all the states of the switch into account.

(defun flick (switch)
  (ecase-of switch-state (state switch)
    (:on (switch-off switch))
    (:off (switch-on switch))))
=> Warning

(defun flick (switch)
  (ecase-of switch-state (state switch)
    (:on (switch-off switch))
    (:off (switch-on switch))
    ((:stuck :broken) (error "Sorry, can't flick ~a" switch))))
=> No warning

Example: union types

(defun negative-integer? (n)
  (etypecase-of t n
    ((not integer) nil)
    ((integer * -1) t)
    ((integer 1 *) nil)))
=> Warning

(defun negative-integer? (n)
  (etypecase-of t n
    ((not integer) nil)
    ((integer * -1) t)
    ((integer 1 *) nil)
    ((integer 0) nil)))
=> No warning

CLOS

Serapeum includes some utilities for CLOS. These utilities do nothing earthshaking, but since the function reference does not include them, they should be documented somewhere.

Method combination: standard with context

Serapeum exports a method combination, serapeum:standard/context. You may recognize it as the wrapping-standard method combination due to Tim Bradshaw.

Generic functions defined with standard/context behave the same as ordinary generic functions, except that they allow an extra qualifier, :context. This extra qualifier works almost like :around, except instead of being run in most-specific-first order, like methods defined with :around, methods defined with :context are run in most-specific-last order. Furthermore, :context methods take priority over any other methods, including :around methods.

The big idea is that a class can use :context methods to make sure that any methods defined by subclasses – even :around methods – run in a certain dynamic context.

Metaclass: topmost-object-class

In most cases, when I write a metaclass, I want all of the classes defined using that metaclass to inherit from a specific class. Injecting a topmost class is not difficult to do, but it involves a certain amount of boilerplate.

To eliminate that boilerplate, Serapeum exports a metaclass, topmost-object-class, to use as a base class for your metaclasses. When you define a metaclass, all you have to do to ensure that classes defined using your metaclass inherit from a specific class is to supply the name of the class to inherit from in the definition of the metaclass. This is much better demonstrated than explained:

;;; The class to inherit from.
(defclass my-topmost-object ()
  ())

;;; The metaclass.
(defclass my-metaclass (serapeum:topmost-object-class)
  ()
  (:default-initargs
   :topmost-class 'my-topmost-object))

(defclass my-class ()
  ()
  (:metaclass my-metaclass))

(typep (make-instance 'my-class) 'my-topmost-object) => t

Note that, since the topmost object is usually a standard class, there is a validate-superclass method which allows an instance of topmost-object-class to inherit from a standard class.

Function reference

The complete reference is in a separate file.

(Note that the reference is generated from docstrings, and should not be edited by hand.)


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

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


Previous: , Up: Systems   [Contents][Index]

2.1 serapeum

Author

Paul M. Rodriguez <pmr@ruricolist.com>

License

MIT

Description

Utilities beyond Alexandria.

Dependencies
Source

serapeum.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Modules

Modules are listed depth-first from the system components tree.


Next: , Previous: , Up: Modules   [Contents][Index]

3.1 serapeum/level0

Dependency

package.lisp (file)

Parent

serapeum (system)

Location

Components

Next: , Previous: , Up: Modules   [Contents][Index]

3.2 serapeum/level1

Dependency

level0 (module)

Parent

serapeum (system)

Location

Components

Previous: , Up: Modules   [Contents][Index]

3.3 serapeum/level2

Dependency

level1 (module)

Parent

serapeum (system)

Location

Components

Next: , Previous: , Up: Top   [Contents][Index]

4 Files

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


Previous: , Up: Files   [Contents][Index]

4.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.1 serapeum.asd

Location

serapeum.asd

Systems

serapeum (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.2 serapeum/package.lisp

Parent

serapeum (system)

Location

package.lisp

Packages

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.3 serapeum/level0/macro-tools.lisp

Parent

level0 (module)

Location

macro-tools.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.4 serapeum/level0/types.lisp

Parent

level0 (module)

Location

types.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.5 serapeum/level0/definitions.lisp

Dependencies
Parent

level0 (module)

Location

definitions.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.6 serapeum/level0/defining-types.lisp

Dependencies
Parent

level0 (module)

Location

defining-types.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.7 serapeum/level0/binding.lisp

Dependency

macro-tools.lisp (file)

Parent

level0 (module)

Location

binding.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.8 serapeum/level0/control-flow.lisp

Dependency

macro-tools.lisp (file)

Parent

level0 (module)

Location

control-flow.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.9 serapeum/level0/threads.lisp

Parent

level0 (module)

Location

threads.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.10 serapeum/level0/iter.lisp

Dependency

macro-tools.lisp (file)

Parent

level0 (module)

Location

iter.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.11 serapeum/level0/conditions.lisp

Parent

level0 (module)

Location

conditions.lisp

Exported Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.12 serapeum/level0/op.lisp

Parent

level0 (module)

Location

op.lisp

Packages

serapeum/op

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.13 serapeum/level0/functions.lisp

Dependencies
Parent

level0 (module)

Location

functions.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.14 serapeum/level0/trees.lisp

Dependency

macro-tools.lisp (file)

Parent

level0 (module)

Location

trees.lisp

Exported Definitions
Internal Definitions

reuse-cons (function)


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.15 serapeum/level0/hash-tables.lisp

Dependencies
Parent

level0 (module)

Location

hash-tables.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.16 serapeum/level0/files.lisp

Dependency

types.lisp (file)

Parent

level0 (module)

Location

files.lisp

Exported Definitions
Internal Definitions

file=/loop (function)


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.17 serapeum/level0/symbols.lisp

Dependency

macro-tools.lisp (file)

Parent

level0 (module)

Location

symbols.lisp

Exported Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.18 serapeum/level0/arrays.lisp

Parent

level0 (module)

Location

arrays.lisp

Exported Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.19 serapeum/level0/queue.lisp

Dependency

types.lisp (file)

Parent

level0 (module)

Location

queue.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.20 serapeum/level0/box.lisp

Dependencies
Parent

level0 (module)

Location

box.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.21 serapeum/level0/numbers.lisp

Dependencies
Parent

level0 (module)

Location

numbers.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.22 serapeum/level0/octets.lisp

Dependency

types.lisp (file)

Parent

level0 (module)

Location

octets.lisp

Exported Definitions
Internal Definitions

octet-vector=/unsafe (function)


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.23 serapeum/level0/time.lisp

Parent

level0 (module)

Location

time.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.24 serapeum/level0/clos.lisp

Parent

level0 (module)

Location

clos.lisp

Exported Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.25 serapeum/level0/hooks.lisp

Parent

level0 (module)

Location

hooks.lisp

Exported Definitions
Internal Definitions

with-hook-restart (macro)


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.26 serapeum/level0/fbind.lisp

Dependencies
Parent

level0 (module)

Location

fbind.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.27 serapeum/level1/lists.lisp

Parent

level1 (module)

Location

lists.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.28 serapeum/level1/sequences.lisp

Parent

level1 (module)

Location

sequences.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.29 serapeum/level1/strings.lisp

Dependency

sequences.lisp (file)

Parent

level1 (module)

Location

strings.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.30 serapeum/level1/vectors.lisp

Parent

level1 (module)

Location

vectors.lisp

Exported Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.31 serapeum/level2/vector=.lisp

Parent

level2 (module)

Location

vector=.lisp

Packages

serapeum/vector=

Exported Definitions

vector= (function)

Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.32 serapeum/level2/mop.lisp

Parent

level2 (module)

Location

mop.lisp

Packages

serapeum/mop

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.33 serapeum/level2/internal-definitions.lisp

Parent

level2 (module)

Location

internal-definitions.lisp

Packages

serapeum/internal-definitions

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.34 serapeum/level2/tree-case.lisp

Parent

level2 (module)

Location

tree-case.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.35 serapeum/level2/dispatch-case.lisp

Parent

level2 (module)

Location

dispatch-case.lisp

Packages

serapeum/dispatch-case

Exported Definitions
Internal Definitions

Previous: , Up: Lisp files   [Contents][Index]

4.1.36 serapeum/level2/range.lisp

Dependency

dispatch-case.lisp (file)

Parent

level2 (module)

Location

range.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

5.1 serapeum-user

Source

package.lisp (file)

Use List

Next: , Previous: , Up: Packages   [Contents][Index]

5.2 serapeum

Utilities beyond Alexandria.

Source

package.lisp (file)

Use List
Used By List
Exported Definitions
Internal Definitions

Next: , Previous: , Up: Packages   [Contents][Index]

5.3 serapeum/op

Source

op.lisp (file)

Use List
Internal Definitions

Next: , Previous: , Up: Packages   [Contents][Index]

5.4 serapeum/vector=

Source

vector=.lisp (file)

Use List
Internal Definitions

Next: , Previous: , Up: Packages   [Contents][Index]

5.5 serapeum/mop

Source

mop.lisp (file)

Use List
Internal Definitions

Next: , Previous: , Up: Packages   [Contents][Index]

5.6 serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Use List
Internal Definitions

Previous: , Up: Packages   [Contents][Index]

5.7 serapeum/dispatch-case

Source

dispatch-case.lisp (file)

Use List
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

6 Definitions

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


Next: , Previous: , Up: Definitions   [Contents][Index]

6.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.1 Special variables

Special Variable: *hook*

The hook currently being run.

Package

serapeum

Source

hooks.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.2 Symbol macros

Symbol Macro: whitespace
Package

serapeum

Source

strings.lisp (file)

Expansion

serapeum::+storage-for-deflex-var-whitespace+


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.3 Macros

Macro: -> FUNCTION ARGS VALUES

Declaim the ftype of FUNCTION from ARGS to VALUES.

(-> mod-fixnum+ (fixnum fixnum) fixnum) (defun mod-fixnum+ (x y) ...)

Package

serapeum

Source

types.lisp (file)

Macro: and-let* (&rest CLAUSES) &body BODY

Scheme’s guarded LET* (SRFI-2).

Each clause should have one of the following forms:

- ‘identifier’, in which case IDENTIFIER’s value is tested.

- ‘(expression)’, in which case the value of EXPRESSION is tested.

- ‘(identifier expression)’ in which case EXPRESSION is evaluated, and, if its value is not false, IDENTIFIER is bound to that value for the remainder of the clauses and the optional body.

Note that, of course, the semantics are slightly different in Common Lisp than in Scheme, because our AND short-circuits on null, not false.

Package

serapeum

Source

binding.lisp (file)

Macro: assure TYPE-SPEC &body FORM

Macro for inline type checking.

‘assure’ is to ‘the’ as ‘check-type’ is to ‘declare’.

(the string 1) => undefined
(assure string 1) => error

The value returned from the ‘assure’ form is guaranteed to satisfy TYPE-SPEC. If FORM does not return a value of that type, then a correctable error is signaled. You can supply a value of the correct type with the ‘use-value’ restart.

Note that the supplied value is *not* saved into the place designated by FORM. (But see ‘assuref’.)

From ISLISP.

Package

serapeum

Source

types.lisp (file)

Macro: assuref PLACE TYPE-SPEC

Like ‘(progn (check-type PLACE TYPE-SPEC) PLACE)‘, but evaluates PLACE only once.

Package

serapeum

Source

types.lisp (file)

Macro: bcond &body CLAUSES

Scheme’s extended COND.

This is exactly like COND, except for clauses having the form

(test :=> recipient)

In that case, if TEST evaluates to a non-nil result, then RECIPIENT, a function, is called with that result, and the result of RECIPIENT is return as the value of the ‘cond‘.

As an extension, a clause like this:

(test :=> var ...)

Can be used as a shorthand for

(test :=> (lambda (var) ...))

The name ‘bcond’ for a “binding cond” goes back at least to the days of the Lisp Machines. I do not know who was first to use it, but the oldest examples I have found are by Michael Parker and Scott L. Burson.

Package

serapeum

Source

control-flow.lisp (file)

Macro: block-compile (&key ENTRY-POINTS BLOCK-COMPILE) &body BODY

Shorthand for block compilation with ‘local*’.

Only the functions in ENTRY-POINTS will have global definitions. All other functions in BODY will be compiled as purely local functions, and all of their calls to one another will be compiled as local calls. This includes calls to the entry points, and even self-calls from within the entry points.

Note that ‘declaim’ forms occuring inside of BODY will be translated into local ‘declare’ forms.

If you pass ‘:block-compile nil’, this macro is equivalent to progn. This may be useful during development.

Package

serapeum

Source

internal-definitions.lisp (file)

Macro: callf FUNCTION PLACE &rest ARGS

Set PLACE to the value of calling FUNCTION on PLACE, with ARGS.

Package

serapeum

Source

macro-tools.lisp (file)

Macro: callf2 FUNCTION ARG1 PLACE &rest ARGS

Like CALLF, but with the place as the second argument.

Package

serapeum

Source

macro-tools.lisp (file)

Macro: case-let (VAR EXPR) &body CASES

Like (let ((VAR EXPR)) (case VAR ...))

Package

serapeum

Source

control-flow.lisp (file)

Macro: case-of TYPE X &body CLAUSES

Like ‘case’ but may, and must, have an ‘otherwise’ clause.

Package

serapeum

Source

control-flow.lisp (file)

Macro: case-using PRED KEYFORM &body CLAUSES

ISLISP’s case-using.

(case-using #’eql x ...)
≡ (case x ...).

Note that, no matter the predicate, the keys are not evaluated. (But see ‘selector’.)

This version supports both single-item clauses (x ...) and
multiple-item clauses ((x y) ...), as well as (t ...) or (otherwise
...) for the default clause.

Package

serapeum

Source

control-flow.lisp (file)

Macro: ccase-of TYPE KEYPLACE &body BODY

Like ‘ecase-of’, but providing a ‘store-value’ restart to correct KEYPLACE and try again.

Package

serapeum

Source

control-flow.lisp (file)

Macro: char-case KEYFORM &body CLAUSES

Like ‘case’, but specifically for characters.
Expands into ‘tree-case’.

As an extension to the generalized ‘case’ syntax, the keys of a clause can be specified as a literal string.

(defun vowel? (c)
(char-case c
("aeiouy" t)))

Signals an error if KEYFORM does not evaluate to a character.

Package

serapeum

Source

tree-case.lisp (file)

Macro: char-ecase KEYFORM &body CLAUSES

Like ‘ecase’, but specifically for characters. Expands into ‘tree-case’.

Package

serapeum

Source

tree-case.lisp (file)

Macro: collecting &body BODY

Like ‘with-collector’, with the collector bound to the result of interning ‘collect’ in the current package.

Package

serapeum

Source

iter.lisp (file)

Macro: comment &body BODY

A macro that ignores its body and does nothing. Useful for comments-by-example.

Also, as noted in EXTENSIONS.LISP of 1992, "This may seem like a silly macro, but used inside of other macros or code generation facilities it is very useful - you can see comments in the (one-time) macro expansion!"

Package

serapeum

Source

control-flow.lisp (file)

Macro: cond-every &body CLAUSES

Like ‘cond’, but instead of stopping after the first clause that succeeds, run all the clauses that succeed.

Return the value of the last successful clause.

If a clause begins with ‘cl:otherwise’, it runs only if no preceding form has succeeded.

Note that this does *not* do the same thing as a series of ‘when’ forms: ‘cond-every’ evaluates *all* the tests *before* it evaluates any of the forms.

From Zetalisp.

Package

serapeum

Source

control-flow.lisp (file)

Macro: cond-let VAR &body CLAUSES

Cross between COND and LET.

(cond-let x ((test ...)))
≡ (let (x)
(cond ((setf x test) ...)))

Cf. ‘acond’ in Anaphora.

Package

serapeum

Source

control-flow.lisp (file)

Macro: ctypecase-of TYPE KEYPLACE &body BODY

Like ‘etypecase-of’, but providing a ‘store-value’ restart to correct KEYPLACE and try again.

Package

serapeum

Source

control-flow.lisp (file)

Macro: def VAR &body &optional

The famous "deflex".

Define a top level (global) lexical VAR with initial value VAL,
which is assigned unconditionally as with DEFPARAMETER. If a DOC string is provided, it is attached to both the name |VAR| and the name *STORAGE-FOR-DEFLEX-VAR-|VAR|* as a documentation string of kind ’VARIABLE. The new VAR will have lexical scope and thus may be shadowed by LET bindings without affecting its dynamic (global) value.

The original ‘deflex’ is due to Rob Warnock.

This version of ‘deflex’ differs from the original in the following ways:

- It is possible for VAL to close over VAR.
- On implementations that support it (SBCL, CCL, and LispWorks, at the moment) this version creates a backing variable that is "global" or "static", so there is not just a change in semantics, but also a
gain in efficiency.
- If VAR is a list that starts with ‘values‘, each element is treated as a separate variable and initialized as if by ‘(setf (values VAR...) VAL)‘.

Package

serapeum

Source

definitions.lisp (file)

Macro: defalias ALIAS &body DEF

Define a value as a top-level function.

(defalias string-gensym (compose #’gensym #’string))

Like (setf (fdefinition ALIAS) DEF), but with a place to put documentation and some niceties to placate the compiler.

Name from Emacs Lisp.

Package

serapeum

Source

definitions.lisp (file)

Macro: defcondition NAME SUPERS &body SLOTS

Alias for ‘define-condition’.

Like (define-condition ...), but blissfully conforming to the same nomenclatural convention as every other definition form in Common Lisp.

Package

serapeum

Source

defining-types.lisp (file)

Macro: defconst SYMBOL INIT &optional DOCSTRING

Define a constant, lexically.

‘defconst’ defines a constant using a strategy similar to ‘def’, so you don’t have to +cage+ your constants.

The constant is only redefined on re-evaluation if INIT has a different literal representation than the old value.

The name is from Emacs Lisp.

Package

serapeum

Source

definitions.lisp (file)

Macro: defconstructor TYPE-NAME &body SLOTS

A variant of ‘defstruct’ for modeling immutable data.

The structure defined by ‘defconstructor’ has only one constructor, which takes its arguments as required arguments (a BOA constructor). Thus, ‘defconstructor’ is only appropriate for data structures that require no initialization.

The printed representation of an instance resembles its constructor:

(person "Common Lisp" 33)
=> (PERSON "Common Lisp" 33)

While the constructor is BOA, the copier takes keyword arguments, allowing you to override the values of a selection of the slots of the structure being copied, while retaining the values of the others.

(defconstructor person
(name string)
(age (integer 0 1000)))

(defun birthday (person)
(copy-person person :age (1+ (person-age person))))

(birthday (person "Common Lisp" 33))
=> (PERSON "Common Lisp" 34)

Obviously the copier becomes more useful the more slots the type has.

When ‘*print-readably*’ is true, the printed representation is readable:

(person "Common Lisp" 33)
=> #.(PERSON "Common Lisp" 33)

(Why override how a structure is normally printed? Structure types are not necessarily readable unless they have a default (‘make-X’) constructor. Since the type defined by ‘defconstructor’ has only one constructor, we have to take over to make sure it re-readable.)

Besides being re-readable, the type is also externalizable, with a method for ‘make-load-form’:

(make-load-form (person "Common Lisp" 33))
=> (PERSON "Common Lisp" 33)

Users of Trivia get an extra benefit: defining a type with ‘defconstructor’ also defines a symmetrical pattern for destructuring that type.

(trivia:match (person "Common Lisp" 33)
((person name age)
(list name age)))
=> ("Common Lisp" 33)

Note that the arguments to the pattern are optional:

(trivia:match (person "Common Lisp" 33)
((person name) name))
=> "Common Lisp"

If you don’t use Trivia, you can still do destructuring with ‘deconstruct’, which returns the slots of a constructor as multiple values:

(deconstruct (person "Common Lisp" 33))
=> "Common Lisp", 33

Note also that no predicate is defined for the type, so to test for the type you must either use ‘typep’ or pattern matching as above.

While it is possible to inherit from a type defined with ‘defconstructor’ (this is Lisp, I can’t stop you), it’s a bad idea. In particular, on Lisps which support it, a type defined with ‘defconstructor’ is declared to be frozen (sealed), so your new subtype may not be recognized in type tests.

Because ‘defconstructor’ is implemented on top of ‘defstruct-read-only’, it shares the limitations of ‘defstruct-read-only’. In particular it cannot use inheritance.

The design of ‘defconstructor’ is mostly inspired by Scala’s [case classes](https://docs.scala-lang.org/tour/case-classes.html), with some implementation tricks from ‘cl-algebraic-data-type’.

Package

serapeum

Source

defining-types.lisp (file)

Macro: define-case-macro NAME MACRO-ARGS PARAMS &body MACRO-BODY

Define a macro like ‘case’.

A case-like macro is one that supports the following syntax:

- A list of keys is treated as matching any key in the list.
- An empty list matches nothing.
- The atoms T or ‘otherwise’ introduce a default clause.
- There can only be one default clause.
- The default clause must come last.
- Any atom besides the empty list, T, or ‘otherwise’ matches itself.

As a consequence of the above, to match against the empty list, T, or ‘otherwise’, they must be wrapped in a list.

(case x
((nil) "Matched nil.")
((t) "Matched t.")
((otherwise) "Matched ‘otherwise’.")
(otherwise "Didn’t match anything."))

A macro defined using ‘define-case-macro’ can ignore all of the above. It receives three arguments: the expression, already protected against multiple evaluation; a normalized list of clauses; and, optionally, a default clause.

The clauses are normalized as a list of ‘(key . body)’, where each key is an atom. (That includes nil, T, and ‘otherwise’.) Nonetheless, each body passed to the macro will only appear once in the expansion; there will be no duplicated code.

The body of the default clause is passed separately,
bound to the value of the ‘:default’ keyword in PARAMS.

(define-case-macro my-case (expr &body clauses)
(:default default)
....)

Note that in this case, ‘default’ will be bound to the clause’s body – a list of forms – and not to the whole clause. The key of the default clause is discarded.

If no binding is specified for the default clause, then no default clause is allowed.

One thing you do still have to consider is the handling of duplicated keys. The macro defined by ‘define-case-macro’ will reject case sets that contains duplicate keys under ‘eql’, but depending on the semantics of your macro, you may need to check for duplicates under a looser definition of equality.

As a final example, if the ‘case’ macro did not already exist, you could define it almost trivially using ‘define-case-macro’:

(define-case-macro my-case (expr &body clause)
(:default default)
‘(cond
,@(loop for (key . body) in clauses
collect ‘((eql ,expr ,key) ,@body))
(t ,@body)))

Package

serapeum

Source

macro-tools.lisp (file)

Macro: define-do-macro NAME BINDS &body BODY

Define an iteration macro like ‘dolist’.

Writing a macro like ‘dolist’ is more complicated than it looks. For consistency with the rest of CL, you have to do all of the following:

- The entire loop must be surrounded with an implicit ‘nil’ block.
- The body of the loop must be an implicit ‘tagbody’.
- There must be an optional ‘return’ form which, if given, supplies
the values to return from the loop.
- While this return form is being evaluated, the iteration variables
must be bound to ‘nil’.

Say you wanted to define a ‘do-hash’ macro that iterates over hash
tables. A full implementation would look like this:

(defmacro do-hash ((key value hash-table &optional return) &body body) (multiple-value-bind (body decls) (parse-body body)
‘(block nil
(maphash (lambda (,key ,value)
,@decls
(tagbody
,@body))
,hash-table)
,(when return
‘(let (,key ,value)
,return)))))

Using ‘define-do-macro’ takes care of all of this for you.

(define-do-macro do-hash ((key value hash-table &optional return) &body body) ‘(maphash (lambda (,key ,value)
,@body)
,hash-table))

Package

serapeum

Source

macro-tools.lisp (file)

Macro: define-post-modify-macro NAME LAMBDA-LIST FUNCTION &optional DOCUMENTATION

Like ‘define-modify-macro’, but arranges to return the original value.

Package

serapeum

Source

macro-tools.lisp (file)

Macro: define-train NAME ARGS &body BODY

Define a higher-order function and its compiler macro at once.

When defining a higher-order function it is usually a good idea to write a compiler macro so compilers can inline the resulting lambda form.

For the special case of a fixed-arity function that only takes other functions as arguments, you can use ‘define-train’ to define the function and the compiler macro in one go. The catch is that you have to write the single definition as a macro.

E.g., if ‘complement’ did not exist, you could define it like so:

(define-train complement (fn)
‘(lambda (&rest args)
(not (apply ,fn args))))

Besides providing an implicit compiler macro, ‘define-train’ also inserts the proper declarations to ensure the compiler recognizes the function arguments as functions.

The term "train" is from J.

Package

serapeum

Source

functions.lisp (file)

Macro: define-values VALUES &body EXPR

Like ‘def’, but for multiple values.
Each variable in VALUES is given a global, lexical binding, as with ‘def’, then set all at once, as with ‘multiple-value-setq’.

Package

serapeum

Source

definitions.lisp (file)

Macro: defloop NAME ARGS &body BODY

Define a function, ensuring proper tail recursion. This is entirely equivalent to ‘defun’ over ‘nlet’.

Package

serapeum

Source

definitions.lisp (file)

Macro: defmethods CLASS (SELF . SLOTS) &body BODY

Concisely define methods that specialize on the same class.

You can already use ‘defgeneric’ to define an arbitrary number of methods on a single generic function without having to repeat the name of the function:

(defgeneric fn (x)
(:method ((x string)) ...)
(:method ((x number)) ...))

Which is equivalent to:

(defgeneric fn (x))

(defmethod fn ((x string))
...)

(defmethod fn ((x number))
...)

Similarly, you can use ‘defmethods’ to define methods that specialize on the same class, and access the same slots, without having to repeat the names of the class or the slots:

(defmethods my-class (self x y)
(:method initialize-instance :after (self &key)
...)
(:method print-object (self stream)
...)
(:method some-method ((x string) self)
...))

Which is equivalent to:

(defmethod initialize-instance :after ((self my-class) &key) (with-slots (x y) self
...))

(defmethod print-object ((self my-class) stream)
(with-slots (x y) self
...))

(defmethod some-method ((x string) (self my-class)) (with-slots (y) self ;!
...))

Note in particular that ‘self’ can appear in any position, and that you can freely specialize the other arguments.

(The difference from using ‘with-slots’ is the scope of the slot bindings: they are established *outside* of the method definition, which means argument bindings shadow slot bindings:

(some-method "foo" (make ’my-class :x "bar"))
=> "foo"

Since slot bindings are lexically outside the argument bindings, this is surely correct, even if it makes ‘defmethods’ slightly harder to explain in terms of simpler constructs.)

Is ‘defmethods’ trivial? Yes, in terms of its implementation. This docstring is far longer than the code it documents. But you may find it does a lot to keep heavily object-oriented code readable and organized, without any loss of power.

This construct is very loosely inspired by impl blocks in Rust.

Package

serapeum

Source

clos.lisp (file)

Macro: defplace NAME ARGS &body FORM

Define NAME and (SETF NAME) in one go.

Note that the body must be a single, setf-able expression.

Package

serapeum

Source

definitions.lisp (file)

Macro: defstruct-read-only NAME-AND-OPTS &body SLOTS

Easily define a defstruct with no mutable slots.

The syntax of ‘defstruct-read-only’ is as close as possible to that of ‘defstruct’. Given an existing structure definition, you can usually make it immutable simply by switching out ‘defstruct’ for ‘defstruct-read-only’.

There are only a few syntactic differences:

1. To prevent accidentally inheriting mutable slots, ‘defstruct-read-only’ does not allow inheritance.

2. The ‘:type’ option may not be used.

3. The ‘:copier’ option is disabled, because it would be useless.

4. Slot definitions can use slot options without having to provide an initform. In this case, any attempt to make an instance of the struct without providing a value for that slot will signal an error.

(my-slot :type string)
≡ (my-slot (required-argument ’my-slot) :read-only t :type string)

The idea here is simply that an unbound slot in an immutable data structure does not make sense.

A read-only struct is always externalizable; it has an implicit definition for ‘make-load-form’.

On Lisps that support it, the structure is also marked as "pure": that is, instances may be moved into read-only memory.

‘defstruct-read-only’ is designed to stay as close to the syntax of ‘defstruct’ as possible. The idea is to make it easy to flag data as immutable, whether in your own code or in code you are refactoring. In new code, however, you may sometimes prefer ‘defconstructor’, which is designed to facilitate working with immutable data.

Package

serapeum

Source

defining-types.lisp (file)

Macro: defsubst NAME PARAMS &body BODY

Define an inline function.

(defsubst fn ...)
≡ (declaim (inline fn))
(defun fn ...)

The advantage of a separate defining form for inline functions is that you can’t forget to declaim the function inline before defining it – without which it may not actually end up being inlined.

From Emacs and other ancient Lisps.

Package

serapeum

Source

definitions.lisp (file)

Macro: defunion UNION &body VARIANTS

Define an algebraic data type.

Each expression in VARIANTS is either a symbol (in which case it defines a unit type, as with ‘defunit’) or a list (in which case it defines a structure, as with ‘defconstructor’.

Package

serapeum

Source

defining-types.lisp (file)

Macro: defunit NAME &optional DOCSTRING

Define a unit type.

A unit type is a type with only one instance.

You can think of a unit type as a singleton without state.

Unit types are used for many of the same purposes as quoted symbols (or keywords) but, unlike a symbol, a unit type is tagged with its own individual type.

Package

serapeum

Source

defining-types.lisp (file)

Macro: defvar-unbound VAR &body DOCSTRING

Define VAR as if by ‘defvar’ with no init form, and set DOCSTRING as its documentation.

I believe the name comes from Edi Weitz.

Package

serapeum

Source

definitions.lisp (file)

Macro: destructuring-case-of TYPE EXPR &body BODY

Like ‘destructuring-ecase-of’, but an ‘otherwise’ clause must also be supplied.

Note that the otherwise clauses must also be a list:

((otherwise &rest args) ...)

Package

serapeum

Source

control-flow.lisp (file)

Macro: destructuring-ccase-of TYPE KEYPLACE &body BODY

Like ‘destructuring-case-of’, but providing a ‘store-value’ restart to collect KEYPLACE and try again.

Package

serapeum

Source

control-flow.lisp (file)

Macro: destructuring-ecase-of TYPE EXPR &body BODY

Like ‘destructuring-ecase’, from Alexandria, but with exhaustivness checking.

TYPE is a designator for a type, which should be defined as ‘(member ...)’. At compile time, the macro checks that, taken together, the symbol at the head of each of the destructuring lists in BODY form an exhaustive partition of TYPE, and warns if it is not so.

Package

serapeum

Source

control-flow.lisp (file)

Macro: dictq &rest KEYS-AND-VALUES

A literal hash table.
Like ‘dict’, but the keys and values are implicitly quoted, and the hash table is inlined as a literal object.

Package

serapeum

Source

hash-tables.lisp (file)

Macro: dispatch-case (&rest EXPRS-AND-TYPES) &body CLAUSES

Dispatch on the types of multiple expressions, exhaustively.

Say you are working on a project where you need to handle timestamps represented both as universal times, and as instances of ‘local-time:timestamp’. You start by defining the appropriate types:

(defpackage :dispatch-case-example
(:use :cl :alexandria :serapeum :local-time)
(:shadow :time))
(in-package :dispatch-case-example)

(deftype universal-time ()
’(integer 0 *))

(deftype time ()
’(or universal-time timestamp))

Now you want to write a ‘time=’ function that works on universal times, timestamps, and any combination thereof.

You can do this using ‘etypecase-of’:

(defun time= (t1 t2)
(etypecase-of time t1
(universal-time
(etypecase-of time t2
(universal-time
(= t1 t2))
(timestamp
(= t1 (timestamp-to-universal t2))))) (timestamp
(etypecase-of time t2
(universal-time
(time= t2 t1))
(timestamp
(timestamp= t1 t2))))))

This has the advantage of efficiency and exhaustiveness checking, but the serious disadvantage of being hard to read: to understand what each branch matches, you have to backtrack to the enclosing branch. This is bad enough when the nesting is only two layers deep.

Alternately, you could do it with ‘defgeneric’:

(defgeneric time= (t1 t2)
(:method ((t1 integer) (t2 integer))
(= t1 t2))
(:method ((t1 timestamp) (t2 timestamp))
(timestamp= t1 t2))
(:method ((t1 integer) (t2 timestamp))
(= t1 (timestamp-to-universal t2)))
(:method ((t1 timestamp) (t2 integer))
(time= t2 t1)))

This is easy to read, but it has three potential disadvantages. (1) There is no exhaustiveness checking. If, at some point in the future, you want to add another representation of time to your project, the compiler will not warn you if you forget to update ‘time=’. (This is bad enough with only two objects to dispatch on, but with three or more it gets rapidly easier to miss a case.) (2) You cannot use the ‘universal-time’ type you just defined; it is a type, not a class, so you cannot specialize methods on it. (3) You are paying a run-time price for extensibility – the inherent overhead of a generic function – when extensibility is not what you want.

Using ‘dispatch-case’ instead gives you the readability of ‘defgeneric’ with the efficiency and safety of ‘etypecase-of’.

(defun time= (t1 t2)
(dispatch-case ((time t1)
(time t2))
((universal-time universal-time)
(= t1 t2))
((timestamp timestamp)
(timestamp= t1 t2))
((universal-time timestamp)
(= t1 (timestamp-to-universal t2)))
((timestamp universal-time)
(time= t2 t1))))

The syntax of ‘dispatch-case’ is much closer to ‘defgeneric’ than it is to ‘etypecase’. The order in which clauses are defined does not matter, and you can define fallthrough clauses in the same way you would define fallthrough methods in ‘defgeneric’.

Suppose you wanted to write a ‘time=’ function like the one above, but always convert times to timestamps before comparing them. You could write that using ‘dispatch-case’ like so:

(defun time= (x y)
(dispatch-case ((x time)
(y time))
((time universal-time)
(time= x (universal-to-timestamp y)))
((universal-time time)
(time= (universal-to-timestamp x) y))
((timestamp timestamp)
(timestamp= x y))))

Note that this requires only three clauses, where writing it out using nested ‘etypecase-of’ forms would require four clauses. This is a small gain; but with more subtypes to dispatch on, or more objects, such fallthrough clauses become more useful.

Package

serapeum

Source

dispatch-case.lisp (file)

Macro: dispatch-case-let (&rest BINDINGS) &body CLAUSES

Like ‘dispatch-case’, but establish new bindings for each expression.

For example,

(dispatch-case-let (((x string) (expr1))
((y string) (expr2)))
...)

is equivalent to

(let ((x (expr1))
(y (expr2)))
(dispatch-case ((x string)
(y string))
...))

It may be helpful to think of this as a cross between
‘defmethod’ (where the (variable type) notation is used in the lambda list) and ‘let’ (which has an obvious macro-expansion in terms of ‘lambda’).

Package

serapeum

Source

dispatch-case.lisp (file)

Macro: do-each (VAR SEQ &optional RETURN) &body BODY

Iterate over the elements of SEQ, a sequence. If SEQ is a list, this is equivalent to ‘dolist’.

Package

serapeum

Source

sequences.lisp (file)

Macro: do-hash-table (KEY VALUE TABLE &optional RETURN) &body BODY

Iterate over hash table TABLE, in no particular order.

At each iteration, a key from TABLE is bound to KEY, and the value of that key in TABLE is bound to VALUE.

Package

serapeum

Source

hash-tables.lisp (file)

Macro: ecase-let (VAR EXPR) &body CASES

Like (let ((VAR EXPR)) (ecase VAR ...))

Package

serapeum

Source

control-flow.lisp (file)

Macro: ecase-of TYPE X &body BODY

Like ‘ecase’ but, given a TYPE (which should be defined as ‘(member ...)’), warn, at compile time, unless the keys in BODY are all of TYPE and, taken together, they form an exhaustive partition of TYPE.

Package

serapeum

Source

control-flow.lisp (file)

Macro: econd &body CLAUSES

Like ‘cond’, but signal an error of type ‘econd-failure’ if no clause succeeds.

Package

serapeum

Source

control-flow.lisp (file)

Macro: econd-let SYMBOL &body CLAUSES

Like ‘cond-let’ for ‘econd’.

Package

serapeum

Source

control-flow.lisp (file)

Macro: eif TEST THEN &optional ELSE

Like ‘cl:if’, but expects two branches. Stands for “exhaustive if”.

Package

serapeum

Source

control-flow.lisp (file)

Macro: eif-let BINDS &body THEN

Like ‘alexandria:if-let’, but expects two branches.

Package

serapeum

Source

control-flow.lisp (file)

Macro: ensure PLACE &body NEWVAL

Essentially (or place (setf place newval)).

PLACE is treated as unbound if it returns ‘nil’, signals ‘unbound-slot’, or signals ‘unbound-variable’.

Note that ENSURE is ‘setf’-able, so you can do things like (incf (ensure x 0))

Cf. ‘ensure2’.

Package

serapeum

Source

control-flow.lisp (file)

Setf Expander

(setf ensure) (setf expander)

Setf Expander: (setf ensure) PLACE &body NEWVAL
Package

serapeum

Source

control-flow.lisp (file)

Reader

ensure (macro)

Macro: ensure2 PLACE &body NEWVAL

Like ‘ensure’, but specifically for accessors that return a second value like ‘gethash’.

Package

serapeum

Source

control-flow.lisp (file)

Setf Expander

(setf ensure2) (setf expander)

Setf Expander: (setf ensure2) PLACE &body NEWVAL
Package

serapeum

Source

control-flow.lisp (file)

Reader

ensure2 (macro)

Macro: etypecase-of TYPE X &body BODY

Like ‘etypecase’ but, at compile time, warn unless each clause in BODY is a subtype of TYPE, and the clauses in BODY form an exhaustive partition of TYPE.

Package

serapeum

Source

control-flow.lisp (file)

Macro: eval-always &body BODY

Shorthand for
(eval-when (:compile-toplevel :load-toplevel :execute) ...)

Package

serapeum

Source

control-flow.lisp (file)

Macro: eval-and-compile &body BODY

Emacs’s ‘eval-and-compile’. Alias for ‘eval-always’.

Package

serapeum

Source

control-flow.lisp (file)

Macro: example &body BODY

Like ‘comment’.

Package

serapeum

Source

control-flow.lisp (file)

Macro: fbind BINDINGS &body BODY

Binds values in the function namespace.

That is,
(fbind ((fn (lambda () ...))))
≡ (flet ((fn () ...))),

except that a bare symbol in BINDINGS is rewritten as (symbol symbol).

Package

serapeum

Source

fbind.lisp (file)

Macro: fbind* BINDINGS &body BODY

Like ‘fbind’, but creates bindings sequentially.

Package

serapeum

Source

fbind.lisp (file)

Macro: fbindrec BINDINGS &body BODY

Like ‘fbind’, but creates recursive bindings.

The consequences of referring to one binding in the expression that generates another are undefined.

Package

serapeum

Source

fbind.lisp (file)

Macro: fbindrec* BINDINGS &body BODY

Like ‘fbindrec‘, but the function defined in each binding can be used in successive bindings.

Package

serapeum

Source

fbind.lisp (file)

Macro: fdec REF0 &optional DELTA

Like ‘decf’, but returns the old value instead of the new.

Package

serapeum

Source

numbers.lisp (file)

Macro: filterf PLACE PRED &rest ARGS

Modify-macro for FILTER.
The place designed by the first argument is set to th result of calling FILTER with PRED, the place, and ARGS.

Package

serapeum

Source

sequences.lisp (file)

Macro: finc REF0 &optional DELTA

Like ‘incf’, but returns the old value instead of the new.

An alternative to using -1 as the starting value of a counter, which can prevent optimization.

Package

serapeum

Source

numbers.lisp (file)

Macro: growf PLACE N

Grow the value in a place by a factor.

Package

serapeum

Source

numbers.lisp (file)

Macro: ignoring TYPE &body BODY

An improved version of ‘ignore-errors‘.

The behavior is the same: if an error occurs in the body, the form returns two values, ‘nil‘ and the condition itself.

‘ignoring‘ forces you to specify the kind of error you want to ignore:

(ignoring parse-error
...)

I call it an improvement because I think ‘ignore-errors‘ is too broad: by hiding all errors it becomes itself a source of bugs.

Of course you can still ignore all errors, at the cost of one extra character:

(ignoring error
...)

NB ‘(ignoring t)‘ is a bad idea.

Package

serapeum

Source

conditions.lisp (file)

Macro: letrec (&rest BINDINGS) &body BODY

Recursive LET.
The idea is that functions created in BINDINGS can close over one another, and themselves.

Note that ‘letrec’ only binds variables: it can define recursive functions, but can’t bind them as functions. (But see ‘fbindrec’.)

Package

serapeum

Source

binding.lisp (file)

Macro: letrec* (&rest BINDINGS) &body BODY

Like LETREC, but the bindings are evaluated in order. See Waddell et al., *Fixing Letrec* for motivation.

Cf. ‘fbindrec*’.

Package

serapeum

Source

binding.lisp (file)

Macro: local &body ORIG-BODY

Make internal definitions using top-level definition forms.

Within ‘local’ you can use top-level definition forms and have them create purely local definitions, like ‘let’, ‘labels’, and ‘macrolet’:

(fboundp ’plus) ; => nil

(local
(defun plus (x y)
(+ x y))
(plus 2 2))
;; => 4

(fboundp ’plus) ; => nil

Each form in BODY is subjected to partial expansion (with ‘macroexpand-1’) until either it expands into a recognized definition form (like ‘defun’) or it can be expanded no further.

(This means that you can use macros that expand into top-level definition forms to create local definitions.)

Just as at the real top level, a form that expands into ‘progn’ (or an equivalent ‘eval-when’) is descended into, and definitions that occur within it are treated as top-level definitions.

(Support for ‘eval-when’ is incomplete: ‘eval-when’ is supported only when it is equivalent to ‘progn’).

The recognized definition forms are:

- ‘def’, for lexical variables (as with ‘letrec’)
- ‘define-values’, for multiple lexical variables at once
- ‘defun’, for local functions (as with ‘labels’)
- ‘defalias’, to bind values in the function namespace (like ‘fbindrec*’) - ‘declaim’, to make declarations (as with ‘declare’)
- ‘defconstant’ and ‘defconst’, which behave exactly like symbol macros - ‘define-symbol-macro’, to bind symbol macros (as with ‘symbol-macrolet’)

Also, with serious restrictions, you can use:

- ‘defmacro’, for local macros (as with ‘macrolet’)

(Note that the top-level definition forms defined by Common Lisp
are (necessarily) supplemented by three from Serapeum: ‘def’, ‘define-values’, and ‘defalias’.)

The exact order in which the bindings are made depends on how ‘local’ is implemented at the time you read this. The only guarantees are that variables are bound sequentially; functions can always close over the bindings of variables, and over other functions; and macros can be used once they are defined.

(local
(def x 1)
(def y (1+ x))
y)
=> 2

(local
(defun adder (y)
(+ x y))
(def x 2)
(adder 1))
=> 3

Perhaps surprisingly, ‘let’ forms (as well as ‘let*’ and ‘multiple-value-bind’) *are* descended into; the only difference is that ‘defun’ is implicitly translated into ‘defalias’. This means you can use the top-level idiom of wrapping ‘let’ around ‘defun’.

(local
(let ((x 2))
(defun adder (y)
(+ x y)))
(adder 2))
=> 4

Support for macros is sharply limited. (Symbol macros, on the other hand, are completely supported.)

1. Macros defined with ‘defmacro’ must precede all other expressions.

2. Macros cannot be defined inside of binding forms like ‘let’.

3. ‘macrolet’ is not allowed at the top level of a ‘local’ form.

These restrictions are undesirable, but well justified: it is impossible to handle the general case both correctly and portably, and while some special cases could be provided for, the cost in complexity of implementation and maintenance would be prohibitive.

The value returned by the ‘local’ form is that of the last form in BODY. Note that definitions have return values in ‘local’ just like they do at the top level. For example:

(local
(plus 2 2)
(defun plus (x y)
(+ x y)))

Returns ‘plus’, not 4.

The ‘local’ macro is loosely based on Racket’s support for internal definitions.

Package

serapeum

Source

internal-definitions.lisp (file)

Macro: local* &body BODY

Like ‘local’, but leave the last form in BODY intact.

(local*
(defun aux-fn ...)
(defun entry-point ...))
=>
(labels ((aux-fn ...))
(defun entry-point ...))

Package

serapeum

Source

internal-definitions.lisp (file)

Macro: lret (&rest BINDINGS) &body BODY

Return the initial value of the last binding in BINDINGS. The idea is to create something, initialize it, and then return it.

(lret ((x 1)
(y (make-array 1)))
(setf (aref y 0) x))
=> #(1)

‘lret’ may seem trivial, but it fufills the highest purpose a macro can: it eliminates a whole class of bugs (initializing an object, but forgetting to return it).

Cf. ‘aprog1’ in Anaphora.

Package

serapeum

Source

binding.lisp (file)

Macro: lret* (&rest BINDINGS) &body BODY

Cf. ‘lret’.

Package

serapeum

Source

binding.lisp (file)

Macro: match-of UNION EXPR &body CLAUSES

Do pattern matching on an algebraic data type.

UNION should be an algebraic data type.

Each clause in CLAUSES has a pattern as its first element.

If the pattern is a symbol, it matches a unit type.

If the pattern is a list, it matches a constructor.

If the pattern is an underscore, it introduces a default or fallthrough clause.

If the pattern is a list that starts with ‘or’, it is a disjunction of other patterns.

Package

serapeum

Source

defining-types.lisp (file)

Macro: mvlet (&rest BINDINGS) &body BODY

Parallel (‘let’-like) version of ‘mvlet*’.

Package

serapeum

Source

binding.lisp (file)

Macro: mvlet* (&rest BINDINGS) &body BODY

Expand a series of nested ‘multiple-value-bind’ forms.

‘mvlet*’ is similar in intent to Scheme’s ‘let-values’, but with a different and less parenthesis-intensive syntax. Each binding is a list of

(var var*... expr)

A simple example should suffice to show both the implementation and the motivation:

(defun uptime (seconds)
(mvlet* ((minutes seconds (truncate seconds 60))
(hours minutes (truncate minutes 60))
(days hours (truncate hours 24)))
(declare ((integer 0 *) days hours minutes seconds)) (fmt "~d day~:p, ~d hour~:p, ~d minute~:p, ~d second~:p" days hours minutes seconds)))

Note that declarations work just like ‘let*’.

Package

serapeum

Source

binding.lisp (file)

Macro: nand &rest FORMS

Equivalent to (not (and ...)).

Package

serapeum

Source

control-flow.lisp (file)

Macro: nest &rest THINGS

Like ~>>, but backward.

This is useful when layering ‘with-x’ macros where the order is not important, and extra indentation would be misleading.

For example:

(nest
(with-open-file (in file1 :direction input)) (with-open-file (in file2 :direction output))
...)

Is equivalent to:

(with-open-file (in file1 :direction input)
(with-open-file (in file2 :direction output) ...))

If the outer macro has no arguments, you may omit the parentheses.

(nest
with-standard-io-syntax
...)
≡ (with-standard-io-syntax
...)

From UIOP, based on a suggestion by Marco Baringer.

Package

serapeum

Source

control-flow.lisp (file)

Macro: nix PLACE

Set PLACE to nil and return the old value of PLACE.

This may be more efficient than (shiftf place nil), because it only sets PLACE when it is not already null.

Package

serapeum

Source

control-flow.lisp (file)

Macro: nlet NAME (&rest BINDINGS) &body BODY

Within BODY, bind NAME as a function, somewhat like LABELS, but with the guarantee that recursive calls to NAME will not grow the stack.

‘nlet’ resembles Scheme’s named let, and is used for the same purpose: writing loops using tail recursion. You could of course do this with ‘labels’ as well, at least under some Lisp implementations, but ‘nlet’ guarantees tail call elimination anywhere and everywhere.

(nlet rec ((i 1000000))
(if (= i 0)
0
(rec (1- i))))
=> 0

Beware: because of the way it is written (literally, a GOTO with arguments), ‘nlet’ is limited: self calls must be tail calls. That is, you cannot use ‘nlet’ for true recursion.

The name comes from ‘Let Over Lambda’, but this is a more careful implementation: the function is not bound while the initial arguments are being evaluated, and it is safe to close over the arguments.

Package

serapeum

Source

iter.lisp (file)

Macro: nor &rest FORMS

Equivalent to (not (or ...)).

From Arc.

Package

serapeum

Source

control-flow.lisp (file)

Macro: op &body BODY

GOO’s simple macro for positional lambdas.

An OP is like a lambda without an argument list. Within the body of the OP form, an underscore introduces a new argument.

(reduce (op (set-intersection _ _ :test #’equal)) sets)

You can refer back to each argument by number, starting with _1.

(funcall (op (+ _ _1)) 2) => 4

You can also use positional arguments directly:

(reduce (op (funcall _2 _1)) ...)

Argument lists can be sparse:

(apply (op (+ _1 _3 _5)) ’(1 2 3 4 5)) => 9

Note that OP with a single argument is equivalent to CONSTANTLY:

(funcall (op 1)) => 1

and that OP with a single placeholder is equivalent to IDENTITY:

(funcall (op _) 1) => 1

OP can also be used to define variadic functions by using _* as the placeholder. It is not necessary to use APPLY.

(apply (op (+ _*)) ’(1 2 3 4)) => 10

OP is intended for simple functions – one-liners. Parameters are extracted according to a depth-first walk of BODY. Macro expansion may, or may not, be done depending on the implementation; it should not be relied on. Lexical bindings may, or may not, shadow placeholders – again, it depends on the implementation. (This means, among other things, that nested use of ‘op’ is not a good idea.) Because of the impossibility of a truly portable code walker, ‘op’ will never be a true replacement for ‘lambda’. But even if it were possible to do better, ‘op’ would still only be suited for one-liners. If you need more than a one-liner, then you should be giving your arguments names.

{One thing you *can* count on the ability to use ‘op’ with quasiquotes. If using placeholders inside quasiquotes does not work on your Lisp implementation, that’s a bug, not a limitation.)

Package

serapeum

Source

op.lisp (file)

Macro: opf PLACE EXPR

Like ‘(callf PLACE (op EXPR))’. From GOO.

Package

serapeum

Source

op.lisp (file)

Macro: pop-assoc KEY ALIST &rest ARGS

Like ‘assoc’ but, if there was a match, delete it from ALIST.

From Newlisp.

Package

serapeum

Source

lists.lisp (file)

Macro: receive FORMALS EXPR &body BODY

Stricter version of ‘multiple-value-bind’.

Use ‘receive’ when you want to enforce that EXPR should return a certain number of values, or a minimum number of values.

If FORMALS is a proper list, then EXPR must return exactly as many values – no more and no less – as there are variables in FORMALS.

If FORMALS is an improper list (VARS . REST), then EXPR must return at least as many values as there are VARS, and any further values are bound, as a list, to REST.

Lastly, if FORMALS is a symbol, bind that symbol to all the values returned by EXPR, as if by ‘multiple-value-list’.

From Scheme (SRFI-8).

Package

serapeum

Source

binding.lisp (file)

Macro: select KEYFORM &body CLAUSES

Like ‘case’, but with evaluated keys.

Note that, like ‘case’, ‘select’ interprets a list as the first element of a clause as a list of keys. To use a form as a key, you must add an extra set of parentheses.

(select 2
((+ 2 2) t))
=> T

(select 4
(((+ 2 2)) t))
=> T

From Zetalisp.

Package

serapeum

Source

control-flow.lisp (file)

Macro: selector KEYFORM FN &body CLAUSES

Like ‘select’, but compare using FN.

Note that (unlike ‘case-using’), FN is not evaluated.

From Zetalisp.

Package

serapeum

Source

control-flow.lisp (file)

Macro: shrinkf PLACE N

Shrink the value in a place by a factor.

Package

serapeum

Source

numbers.lisp (file)

Macro: sort-values PRED &rest VALUES

Sort VALUES with PRED and return as multiple values.

Equivalent to

(values-list (sort (list VALUES...) pred))

But with less consing, and potentially faster.

Package

serapeum

Source

control-flow.lisp (file)

Macro: string-case STRINGFORM &body CLAUSES

Efficient ‘case’-like macro with string keys.

Note that string matching is always case-sensitive.

This uses Paul Khuong’s ‘string-case’ macro internally.

Package

serapeum

Source

control-flow.lisp (file)

Macro: string-ecase STRINGFORM &body CLAUSES

Efficient ‘ecase’-like macro with string keys.

Note that string matching is always case-sensitive.

Cf. ‘string-case’.

Package

serapeum

Source

control-flow.lisp (file)

Macro: summing &body BODY

Within BODY, bind ‘sum’ to a function that gathers numbers to sum.

If the first form in BODY is a literal number, it is used instead of 0 as the initial sum.

To see the running sum, call ‘sum’ with no arguments.

Return the total.

Package

serapeum

Source

iter.lisp (file)

Macro: synchronized (&optional OBJECT) &body BODY

Run BODY holding a unique lock associated with OBJECT.
If no OBJECT is provided, run BODY as an anonymous critical section.

If BODY begins with a literal string, attach the string to the lock object created (as the argument to ‘bt:make-recursive-lock’).

Package

serapeum

Source

threads.lisp (file)

Macro: tree-case KEYFORM &body CASES

A variant of ‘case’ optimized for when every key is an integer.

Comparison is done using ‘eql’.

Package

serapeum

Source

tree-case.lisp (file)

Macro: tree-ecase KEYFORM &body CLAUSES

Like ‘tree-case’, but signals an error if KEYFORM does not match any of the provided cases.

Package

serapeum

Source

tree-case.lisp (file)

Macro: typecase-of TYPE X &body CLAUSES

Like ‘etypecase-of’, but may, and must, have an ‘otherwise’ clause in case X is not of TYPE.

Package

serapeum

Source

control-flow.lisp (file)

Macro: vref VEC INDEX

When used globally, same as ‘aref’.

Inside of a with-type-dispatch form, calls to ‘vref’ may be bound to different accessors, such as ‘char’ or ‘schar’, or ‘bit’ or ‘sbit’, depending on the type being specialized on.

Package

serapeum

Source

types.lisp (file)

Macro: with-collector (COLLECTOR) &body BODY

Within BODY, bind COLLECTOR to a function of one argument that accumulates all the arguments it has been called with in order, like the collect clause in ‘loop’, finally returning the collection.

To see the collection so far, call COLLECTOR with no arguments.

Note that this version binds COLLECTOR to a closure, not a macro: you can pass the collector around or return it like any other function.

Package

serapeum

Source

iter.lisp (file)

Macro: with-collectors (&rest COLLECTORS) &body BODY

Like ‘with-collector’, with multiple collectors.
Returns the final value of each collector as multiple values.

(with-collectors (x y z)
(x 1)
(y 2)
(z 3))
=> ’(1) ’(2) ’(3)

Package

serapeum

Source

iter.lisp (file)

Macro: with-string (VAR &optional STREAM) &body BODY

Bind VAR to the character stream designated by STREAM.

STREAM is resolved like the DESTINATION argument to ‘format’: it can be any of t (for ‘*standard-output*’), nil (for a string stream), a string with a fill pointer, or a stream to be used directly.

When possible, it is a good idea for functions that build strings to take a stream to write to, so callers can avoid consing a string just to write it to a stream. This macro makes it easy to write such functions.

(defun format-x (x &key stream)
(with-string (s stream)
...))

Package

serapeum

Source

strings.lisp (file)

Macro: with-string-dispatch (&rest TYPES) VAR &body BODY

Like ‘with-subtype-dispatch’ with an overall type of ‘string’.

Package

serapeum

Source

types.lisp (file)

Macro: with-subtype-dispatch TYPE (&rest SUBTYPES) VAR &body BODY

Like ‘with-type-dispatch’, but SUBTYPES must be subtypes of TYPE.

Furthermore, if SUBTYPES are not exhaustive, an extra clause will be added to ensure that TYPE itself is handled.

Package

serapeum

Source

types.lisp (file)

Macro: with-thunk (VAR &rest ARGS) &body BODY

A macro-writing macro for the ‘call-with-’ style.

In the ‘call-with-’ style of writing macros, the macro is simply a syntactic convenience that wraps its body in a thunk and a call to the function that does the actual work.

(defmacro with-foo (&body body)
‘(call-with-foo (lambda () ,@body)))

The ‘call-with-’ style has many advantages. Functions are easier to write than macros; you can change the behavior of a function without having to recompile all its callers; functions can be traced, appear in backtraces, etc.

But meanwhile, all those thunks are being allocated on the heap. Can we avoid this? Yes, but at a high cost in boilerplate: the closure has to be given a name (using ‘flet’) so it can be declared ‘dynamic-extent’.

(defmacro with-foo (&body body)
(with-gensyms (thunk)
‘(flet ((,thunk () ,@body))
(declare (dynamic-extent #’,thunk))
(call-with-foo #’,thunk))))

‘with-thunk’ avoids the boilerplate:

(defmacro with-foo (&body body)
(with-thunk (body)
‘(call-with-foo ,body)))

It is also possible to construct a "thunk" with arguments.

(with-thunk (body foo)
‘(call-with-foo ,body))
≡ ‘(flet ((,thunk (,foo)
,@body))
(declare (dynamic-extent #’,thunk))
(call-with-foo #’,thunk))

Someday this may have a better name.

Package

serapeum

Source

macro-tools.lisp (file)

Macro: with-type-dispatch (&rest TYPES) VAR &body BODY

A macro for writing fast sequence functions (among other things).

In the simplest case, this macro produces one copy of BODY for each type in TYPES, with the appropriate declarations to induce your Lisp to optimize that version of BODY for the appropriate type.

Say VAR is a string. With this macro, you can trivially emit optimized code for the different kinds of string that VAR might be. And
then (ideally) instead of getting code that dispatches on the type of VAR every time you call ‘aref’, you get code that dispatches on the type of VAR once, and then uses the appropriately specialized accessors. (But see ‘with-string-dispatch’.)

But that’s the simplest case. Using ‘with-type-dispatch’ also provides *transparent portability*. It examines TYPES to deduplicate types that are not distinct on the current Lisp, or that are shadowed by other provided types. And the expansion strategy may differ from Lisp to Lisp: ideally, you should not have to pay for good performance on Lisps with type inference with pointless code bloat on other Lisps.

There is an additional benefit for vector types. Around each version of BODY, the definition of ‘vref’ is shadowed to expand into an appropriate accessor. E.g., within a version of BODY where VAR is known to be a ‘simple-string’, ‘vref’ expands into ‘schar’.

Using ‘vref’ instead of ‘aref’ is obviously useful on Lisps that do not do type inference, but even on Lisps with type inference it can speed compilation times (compiling ‘aref’ is relatively slow on SBCL).

Within ‘with-type-dispatch’, VAR should be regarded as read-only.

Note that ‘with-type-dispatch’ is intended to be used around relatively expensive code, particularly loops. For simpler code, the gains from specialized compilation may not justify the overhead of the initial dispatch and the increased code size.

Note also that ‘with-type-dispatch’ is relatively low level. You may want to use one of the other macros in the same family, such as ‘with-subtype-dispatch’, ‘with-string-dispatch’, or so forth.

The design and implementation of ‘with-type-dispatch’ is based on a few sources. It replaces a similar macro formerly included in Serapeum, ‘with-templated-body’. One possible expansion is based on the ‘string-dispatch’ macro used internally in SBCL. But most of the credit should go to the paper "Fast, Maintable, and Portable Sequence Functions", by Irène Durand and Robert Strandh.

Package

serapeum

Source

types.lisp (file)

Macro: with-vector-dispatch (&rest TYPES) VAR &body BODY

Like ‘with-subtype-dispatch’ with an overall type of ‘vector’.

Package

serapeum

Source

types.lisp (file)

Macro: ~> NEEDLE &rest HOLES

Threading macro from Clojure (by way of Racket).

Thread NEEDLE through HOLES, where each hole is either a
symbol (equivalent to ‘(hole needle)‘) or a list (equivalent to ‘(hole needle args...)‘).

As an extension, an underscore in the argument list is replaced with the needle, so you can pass the needle as an argument other than the first.

Package

serapeum

Source

control-flow.lisp (file)

Macro: ~>> NEEDLE &rest HOLES

Like ‘~>’ but, by default, thread NEEDLE as the last argument instead of the first.

Package

serapeum

Source

control-flow.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.4 Compiler macros

Compiler Macro: @ TABLE KEY &rest KEYS
Package

serapeum

Source

hash-tables.lisp (file)

Compiler Macro: capped-fork G H
Package

serapeum

Source

functions.lisp (file)

Compiler Macro: capped-fork2 G H
Package

serapeum

Source

functions.lisp (file)

Compiler Macro: dict &rest KEYS-AND-VALUES
Package

serapeum

Source

hash-tables.lisp (file)

Compiler Macro: eq* &rest XS
Package

serapeum

Source

control-flow.lisp (file)

Compiler Macro: eql* &rest XS
Package

serapeum

Source

control-flow.lisp (file)

Compiler Macro: equal* &rest XS
Package

serapeum

Source

control-flow.lisp (file)

Compiler Macro: equalp* &rest XS
Package

serapeum

Source

control-flow.lisp (file)

Compiler Macro: escape STRING TABLE &key START END STREAM
Package

serapeum

Source

strings.lisp (file)

Compiler Macro: filter PRED SEQ &rest ARGS &key COUNT &allow-other-keys

In the absence of COUNT, expand directly to ‘remove-if-not’.

Package

serapeum

Source

sequences.lisp (file)

Compiler Macro: filter-map FN LIST &rest LISTS
Package

serapeum

Source

lists.lisp (file)

Compiler Macro: flip F
Package

serapeum

Source

functions.lisp (file)

Compiler Macro: fmt CONTROL-STRING &rest ARGS
Package

serapeum

Source

strings.lisp (file)

Compiler Macro: fork G F H
Package

serapeum

Source

functions.lisp (file)

Compiler Macro: fork2 G F H
Package

serapeum

Source

functions.lisp (file)

Compiler Macro: hook F G
Package

serapeum

Source

functions.lisp (file)

Compiler Macro: hook2 F G
Package

serapeum

Source

functions.lisp (file)

Compiler Macro: href TABLE &rest KEYS
Package

serapeum

Source

hash-tables.lisp (file)

Compiler Macro: in X &rest ITEMS
Package

serapeum

Source

lists.lisp (file)

Compiler Macro: interval &rest ARGS
Package

serapeum

Source

time.lisp (file)

Compiler Macro: juxt &rest FNS
Package

serapeum

Source

functions.lisp (file)

Compiler Macro: keep ITEM SEQ &rest ARGS &key TEST COUNT &allow-other-keys

In the absence of COUNT, expand directly to ‘remove’.

Package

serapeum

Source

sequences.lisp (file)

Compiler Macro: make CLASS &rest INITARGS &key &allow-other-keys
Package

serapeum

Source

clos.lisp (file)

Compiler Macro: mapply FN LIST &rest LISTS
Package

serapeum

Source

lists.lisp (file)

Compiler Macro: memq ITEM LIST
Package

serapeum

Source

lists.lisp (file)

Compiler Macro: mvfold FN SEQ &rest SEEDS

Optimize ‘mvfold’ with a fixed number of seeds.

Package

serapeum

Source

sequences.lisp (file)

Compiler Macro: mvfoldr FN SEQ &rest SEEDS

Optimize ‘mvfoldr’ with a fixed number of seeds.

Package

serapeum

Source

sequences.lisp (file)

Compiler Macro: no X
Package

serapeum

Source

control-flow.lisp (file)

Compiler Macro: nth-arg N
Package

serapeum

Source

functions.lisp (file)

Compiler Macro: nub SEQ &rest ARGS &key TEST &allow-other-keys
Package

serapeum

Source

sequences.lisp (file)

Compiler Macro: of-length LENGTH
Package

serapeum

Source

sequences.lisp (file)

Compiler Macro: once FN
Package

serapeum

Source

functions.lisp (file)

Compiler Macro: parse-float STRING &rest ARGS &key TYPE &allow-other-keys
Package

serapeum

Source

numbers.lisp (file)

Compiler Macro: partial FN &rest ARGS
Package

serapeum

Source

functions.lisp (file)

Compiler Macro: queue &rest XS

When there are no initial elements, use the bare constructor, allowing the queue to be declared dynamic-extent.

Package

serapeum

Source

queue.lisp (file)

Compiler Macro: random-in-range LOW HIGH

When LOW and HIGH are both constants, declare the type of the result.

Package

serapeum

Source

numbers.lisp (file)

Compiler Macro: range START &optional STOP STEP
Package

serapeum

Source

range.lisp (file)

Compiler Macro: seq= &rest XS
Package

serapeum

Source

sequences.lisp (file)

Compiler Macro: string$= SUFFIX STRING &rest ARGS
Package

serapeum

Source

strings.lisp (file)

Compiler Macro: string*= SUBSTRING STRING &rest ARGS
Package

serapeum

Source

strings.lisp (file)

Compiler Macro: string+ &rest ARGS
Package

serapeum

Source

strings.lisp (file)

Compiler Macro: string-contains-p SUBSTRING STRING &rest ARGS
Package

serapeum

Source

strings.lisp (file)

Compiler Macro: string-prefix-p PREFIX STRING &rest ARGS
Package

serapeum

Source

strings.lisp (file)

Compiler Macro: string-replace-all OLD STRING NEW &key START END STREAM COUNT
Package

serapeum

Source

strings.lisp (file)

Compiler Macro: string-suffix-p SUFFIX STRING &rest ARGS
Package

serapeum

Source

strings.lisp (file)

Compiler Macro: string^= PREFIX STRING &rest ARGS
Package

serapeum

Source

strings.lisp (file)

Compiler Macro: true X
Package

serapeum

Source

types.lisp (file)

Compiler Macro: unbox X
Package

serapeum

Source

box.lisp (file)

Compiler Macro: vect &rest INITS
Package

serapeum

Source

vectors.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.5 Functions

Function: @ TABLE &rest KEYS

A concise way of doings lookups in (potentially nested) hash tables.

(@ (dict :x 1) :x) => x
(@ (dict :x (dict :y 2)) :x :y) => y

Package

serapeum

Source

hash-tables.lisp (file)

Writer

(setf @) (function)

Function: (setf @) VALUE TABLE KEY &rest KEYS
Package

serapeum

Source

hash-tables.lisp (file)

Reader

@ (function)

Function: add-hook NAME FN &key APPEND

Add FN to the value of NAME, a hook.

Package

serapeum

Source

hooks.lisp (file)

Function: append1 LIST ITEM

Append an atom to a list.

(append1 list item)
≡ (append list (list item))

Package

serapeum

Source

lists.lisp (file)

Function: array-index-row-major ()

The inverse of ARRAY-ROW-MAJOR-INDEX.

Given an array and a row-major index, return a list of subscripts.

(apply #’aref (array-index-row-major i))
≡ (array-row-major-aref i)

Package

serapeum

Source

arrays.lisp (file)

Function: ascii-char-p CHAR

Is CHAR an ASCII char?

Package

serapeum

Source

strings.lisp (file)

Function: assocadr ITEM ALIST &rest ARGS &key &allow-other-keys

Like ‘assocdr’ for alists of proper lists.

(assocdr ’x ’((x 1))) => ’(1) (assocadr ’x ’((x 1))) => 1

Package

serapeum

Source

lists.lisp (file)

Function: assocdr ITEM ALIST &rest ARGS &key &allow-other-keys

Like (cdr (assoc ...))

Package

serapeum

Source

lists.lisp (file)

Function: assort SEQ &key KEY TEST START END

Return SEQ assorted by KEY.

(assort (iota 10)
:key (lambda (n) (mod n 3)))
=> ’((0 3 6 9) (1 4 7) (2 5 8))

You can think of ‘assort’ as being akin to ‘remove-duplicates’:

(mapcar #’first (assort list))
≡ (remove-duplicates list :from-end t)

Package

serapeum

Source

sequences.lisp (file)

Function: batches SEQ N &key START END EVEN

Return SEQ in batches of N elements.

(batches (iota 11) 2)
=> ((0 1) (2 3) (4 5) (6 7) (8 9) (10))

If EVEN is non-nil, then SEQ must be evenly divisible into batches of size N, with no leftovers.

Package

serapeum

Source

sequences.lisp (file)

Function: bestn N SEQ PRED &key KEY MEMO

Partial sorting.
Equivalent to (firstn N (sort SEQ PRED)), but much faster, at least for small values of N.

With MEMO, use a decorate-sort-undecorate transform to ensure KEY is only ever called once per element.

The name is from Arc.

Package

serapeum

Source

sequences.lisp (file)

Function: bits INT &key BIG-ENDIAN

Return a bit vector of the bits in INT. Defaults to little-endian.

Package

serapeum

Source

numbers.lisp (file)

Function: blankp SEQ

SEQ is either empty, or consists entirely of characters that satisfy ‘whitespacep’.

Package

serapeum

Source

strings.lisp (file)

Function: bound-value S &optional DEFAULT

If S is bound, return (values s t). Otherwise, return DEFAULT and nil.

Package

serapeum

Source

symbols.lisp (file)

Writer

(setf bound-value) (function)

Function: (setf bound-value) VAL SYM

Like ‘(setf (symbol-value SYM) VAL)’, but raises an error if SYM is not already bound.

Package

serapeum

Source

symbols.lisp (file)

Reader

bound-value (function)

Function: box VALUE

Box a value.

Package

serapeum

Source

box.lisp (file)

Function: capped-fork G H

J’s capped fork (monadic).

Like a monadic fork, but F is omitted.

Effectively the composition of G and H.

Package

serapeum

Source

functions.lisp (file)

Function: capped-fork2 G H

J’s capped fork (dyadic).

Like a dyadic fork, but F is omitted.

Package

serapeum

Source

functions.lisp (file)

Function: car-safe X

The car of X, or nil if X is not a cons.

This is different from Alexandria’s ‘ensure-car‘, which returns the atom.

(ensure-car ’(1 . 2)) => 1
(car-safe ’(1 . 2)) => 1
(ensure-car 1) => 1
(car-safe 1) => nil

From Emacs Lisp.

Package

serapeum

Source

lists.lisp (file)

Function: case-failure EXPR KEYS

Signal an error of type ‘case-failure’.

Package

serapeum

Source

macro-tools.lisp (file)

Function: cdr-safe X

The cdr of X, or nil if X is not a cons. From Emacs Lisp.

Package

serapeum

Source

lists.lisp (file)

Function: chomp STRING &optional SUFFIXES

If STRING ends in one of SUFFIXES, remove that suffix.

SUFFIXES defaults to a Lisp newline, a literal line feed, a literal carriage return, or a literal carriage return followed by a literal line feed.

Takes care that the longest suffix is always removed first.

Package

serapeum

Source

strings.lisp (file)

Function: class-name-of X

The class name of the class of X.

Package

serapeum

Source

clos.lisp (file)

Function: class-name-safe X

The class name of the class of X.
If X is a class, the name of the class itself.

Package

serapeum

Source

clos.lisp (file)

Function: clear-queue QUEUE

Return QUEUE’s contents and reset it.

Package

serapeum

Source

queue.lisp (file)

Function: collapse-whitespace STRING

Collapse runs of whitespace in STRING.
Each run of space, newline, and other whitespace characters is replaced by a single space character.

Package

serapeum

Source

strings.lisp (file)

Function: concat &rest STRINGS

Abbreviation for (concatenate ’string ...).

From Emacs Lisp.

Package

serapeum

Source

strings.lisp (file)

Function: date-leap-year-p YEAR

Is YEAR a leap year in the Gregorian calendar?

Package

serapeum

Source

time.lisp (file)

Function: deconstruct X

If X is a type defined with ‘defconstructor’, return its slots as multiple values.

Package

serapeum

Source

defining-types.lisp (file)

Function: delete-from-hash-table TABLE &rest KEYS

Return TABLE with KEYS removed (as with ‘remhash’). Cf. ‘delete-from-plist’ in Alexandria.

Package

serapeum

Source

hash-tables.lisp (file)

Function: delq ITEM LIST

Like (delete ... :test #’eq), but only for lists.

Almost always used as (delq nil ...).

Package

serapeum

Source

lists.lisp (file)

Function: deltas SEQ &optional FN

Return the successive differences in SEQ.

(deltas ’(4 9 -5 1 2))
=> ’(4 5 -14 6 1)

Note that the first element of SEQ is also the first element of the return value.

By default, the delta is the difference, but you can specify another function as a second argument:

(deltas ’(2 4 2 6) #’/)
=> ’(2 2 1/2 3)

From Q.

Package

serapeum

Source

sequences.lisp (file)

Function: deq QUEUE

Remove item from the front of the QUEUE.

Package

serapeum

Source

queue.lisp (file)

Function: dict &rest KEYS-AND-VALUES

A concise constructor for hash tables.

(gethash :c (dict :a 1 :b 2 :c 3)) => 3, T

By default, return an ’equal hash table containing each successive pair of keys and values from KEYS-AND-VALUES.

If the number of KEYS-AND-VALUES is odd, then the first argument is understood as the test.

(gethash "string" (dict "string" t)) => t
(gethash "string" (dict ’eq "string" t)) => nil

Package

serapeum

Source

hash-tables.lisp (file)

Function: dict* DICT &rest ARGS

Merge new bindings into DICT.
Roughly equivalent to ‘(merge-tables DICT (dict args...))’.

Package

serapeum

Source

hash-tables.lisp (file)

Function: distinct &key KEY TEST

Return a function that echoes only values it has not seen before.

(defalias test (distinct))
(test ’foo) => foo, t
(test ’foo) => nil, nil

The second value is T when the value is distinct.

TEST must be a valid test for a hash table.

This has many uses, for example:

(count-if (distinct) seq)
≡ (length (remove-duplicates seq))

Package

serapeum

Source

functions.lisp (file)

Function: drop N SEQ

Return all but the first N elements of SEQ.
The sequence returned is a new sequence of the same type as SEQ.

If N is greater than the length of SEQ, returns an empty sequence of the same type.

If N is negative, then |N| elements are dropped from the end of SEQ.

Package

serapeum

Source

sequences.lisp (file)

Function: drop-while PRED SEQ

Return the largest possible suffix of SEQ for which PRED returns false when called on the first element.

Package

serapeum

Source

sequences.lisp (file)

Function: dsu-sort SEQ FN &key KEY STABLE

Decorate-sort-undecorate using KEY.
Useful when KEY is an expensive function (e.g. database access).

Package

serapeum

Source

sequences.lisp (file)

Function: dynamic-closure SYMBOLS FN

Create a dynamic closure.

Some ancient Lisps had closures without lexical binding. Instead, you could "close over" pieces of the current dynamic environment. When the resulting closure was called, the symbols closed over would be bound to their values at the time the closure was created. These bindings would persist through subsequent invocations and could be mutated. The result was something between a closure and a continuation.

This particular piece of Lisp history is worth reviving, I think, if only for use with threads. For example, to start a thread and propagate the current value of ‘*standard-output*’:

(bt:make-thread (dynamic-closure ’(*standard-output*) (lambda ...))) = (let ((temp *standard-output*))
(bt:make-thread
(lambda ...
(let ((*standard-output* temp))
...))))

Package

serapeum

Source

functions.lisp (file)

Function: efface ITEM LIST

Destructively remove only the first occurence of ITEM in LIST.

From Lisp 1.5.

Package

serapeum

Source

lists.lisp (file)

Function: ellipsize STRING N &key ELLIPSIS

If STRING is longer than N, truncate it and append ELLIPSIS.

Note that the resulting string is longer than N by the length of ELLIPSIS, so if N is very small the string may come out longer than it started.

(ellipsize "abc" 2)
=> "ab..."

From Arc.

Package

serapeum

Source

strings.lisp (file)

Function: enq ITEM QUEUE

Insert ITEM at the end of QUEUE.

Package

serapeum

Source

queue.lisp (file)

Function: eq* &rest XS

Variadic version of ‘EQ’.

With no arguments, return T.

With one argument, return T.

With two arguments, same as ‘EQ’.

With three or more arguments, return T only if all of XS are equivalent under ‘EQ’.

Has a compiler macro, so there is no loss of efficiency relative to writing out the tests by hand.

Package

serapeum

Source

control-flow.lisp (file)

Function: eql* &rest XS

Variadic version of ‘EQL’.

With no arguments, return T.

With one argument, return T.

With two arguments, same as ‘EQL’.

With three or more arguments, return T only if all of XS are equivalent under ‘EQL’.

Has a compiler macro, so there is no loss of efficiency relative to writing out the tests by hand.

Package

serapeum

Source

control-flow.lisp (file)

Function: equal* &rest XS

Variadic version of ‘EQUAL’.

With no arguments, return T.

With one argument, return T.

With two arguments, same as ‘EQUAL’.

With three or more arguments, return T only if all of XS are equivalent under ‘EQUAL’.

Has a compiler macro, so there is no loss of efficiency relative to writing out the tests by hand.

Package

serapeum

Source

control-flow.lisp (file)

Function: equalp* &rest XS

Variadic version of ‘EQUALP’.

With no arguments, return T.

With one argument, return T.

With two arguments, same as ‘EQUALP’.

With three or more arguments, return T only if all of XS are equivalent under ‘EQUALP’.

Has a compiler macro, so there is no loss of efficiency relative to writing out the tests by hand.

Package

serapeum

Source

control-flow.lisp (file)

Function: escape STRING TABLE &key START END STREAM

Write STRING to STREAM, escaping with TABLE.

TABLE should be either a hash table, with characters for keys and strings for values, or a function that takes a character and returns (only) either a string or null.

That is, the signature of TABLE should be:

(function (character) (or string null))

where ‘nil’ means to pass the character through unchanged.

STREAM can be used to specify a stream to write to, like the first argument to ‘format’. The default behavior, with no stream specified, is to return a string.

Package

serapeum

Source

strings.lisp (file)

Function: eval-if-constant FORM &optional ENV

Try to reduce FORM to a constant, using ENV.
If FORM cannot be reduced, return it unaltered.

Also return a second value, T if the form was reduced, or nil otherwise.

This is equivalent to testing if FORM is constant, then evaluting it, except that FORM is macro-expanded in ENV (taking compiler macros into account) before doing the test.

Package

serapeum

Source

macro-tools.lisp (file)

Function: expand-macro FORM &optional ENV

Like ‘macroexpand-1’, but also expand compiler macros. From Swank.

Package

serapeum

Source

macro-tools.lisp (file)

Function: expand-macro-recursively FORM &optional ENV

Like ‘macroexpand’, but also expand compiler macros. From Swank.

Package

serapeum

Source

macro-tools.lisp (file)

Function: extrema SEQ PRED &key KEY START END

Like EXTREMUM, but returns both the minimum and the maximum (as two values).

(extremum (iota 10) #’>) => 9
(extrema (iota 10) #’>) => 9, 0

Package

serapeum

Source

sequences.lisp (file)

Function: file-size FILE &key ELEMENT-TYPE

The size of FILE, in units of ELEMENT-TYPE (defaults to bytes).

The size is computed by opening the file and getting the length of the resulting stream.

If all you want is to read the file’s size in octets from its metadata, consider ‘trivial-file-size:file-size-in-octets’ instead.

Package

serapeum

Source

files.lisp (file)

Function: file= FILE1 FILE2 &key BUFFER-SIZE

Compare FILE1 and FILE2 octet by octet, (possibly) using buffers of BUFFER-SIZE.

Package

serapeum

Source

files.lisp (file)

Function: filter PRED SEQ &rest ARGS &key COUNT &allow-other-keys

Almost, but not quite, an alias for ‘remove-if-not’.

The difference is the handling of COUNT: for ‘filter’, COUNT is the number of items to *keep*, not remove.

(remove-if-not #’oddp ’(1 2 3 4 5) :count 2)
=> ’(1 3 5)

(filter #’oddp ’(1 2 3 4 5) :count 2)
=> ’(1 3)

Package

serapeum

Source

sequences.lisp (file)

Function: filter-map FN LIST &rest LISTS

Map FN over (LIST . LISTS) like ‘mapcar’, but omit empty results.

(filter-map fn ...)
≅ (remove nil (mapcar fn ...))

Package

serapeum

Source

lists.lisp (file)

Function: find-class-safe X &optional ENV

The class designated by X.
If X is a class, it designates itself.

Package

serapeum

Source

clos.lisp (file)

Function: find-keyword STRING

If STRING has been interned as a keyword, return it.

Like ‘make-keyword’, but preferable in most cases, because it doesn’t intern a keyword – which is usually both unnecessary and unwise.

Package

serapeum

Source

symbols.lisp (file)

Function: firstn N LIST

The first N elements of LIST, as a fresh list:

(firstn 4 (iota 10))
=> (0 1 2 4)

(I do not why this extremely useful function did not make it into Common Lisp, unless it was deliberately left out as an exercise for Maclisp users.)

Package

serapeum

Source

lists.lisp (file)

Function: fixnump N

Same as ‘(typep N ’fixnum)’.

Package

serapeum

Source

numbers.lisp (file)

Function: flip F

Flip around the arguments of a binary function.

That is, given a binary function, return another, equivalent function that takes its two arguments in the opposite order.

From Haskell.

Package

serapeum

Source

functions.lisp (file)

Function: flip-hash-table TABLE &key TEST KEY

Return a table like TABLE, but with keys and values flipped.

(gethash :y (flip-hash-table (dict :x :y)))
=> :x, t

TEST allows you to filter which keys to set.

(def number-names (dictq 1 one 2 two 3 three))

(def name-numbers (flip-hash-table number-names))
(def name-odd-numbers (flip-hash-table number-names :filter #’oddp))

(gethash ’two name-numbers) => 2, t
(gethash ’two name-odd-numbers) => nil, nil

KEY allows you to transform the keys in the old hash table.

(def negative-number-names (flip-hash-table number-names :key #’-)) (gethash ’one negative-number-names) => -1, nil

KEY defaults to ‘identity’.

Package

serapeum

Source

hash-tables.lisp (file)

Function: float-precision-contagion &rest NS

Perform numeric contagion on the elements of NS.

That is, if any element of NS is a float, then every number in NS will be returned as "a float of the largest format among all the floating-point arguments to the function".

This does nothing but numeric contagion: the number of arguments returned is the same as the number of arguments given.

Package

serapeum

Source

numbers.lisp (file)

Function: fmt CONTROL-STRING &rest ARGS

A cousin of ‘format‘ expressly for fast formatting of strings.

Like (format nil ...), binding ‘*pretty-pretty*’ to ‘nil’, which in some Lisps means a significant increase in speed.

Has a compiler macro with ‘formatter’.

Package

serapeum

Source

strings.lisp (file)

Function: fork G F H

Monadic fork.

The monadic fork of f, g, and h is defined as

(f g h) y <-> (f y) g (h y)

The usual example of a monadic fork is defining the mean. Assuming a ‘sum’ function defined as

(defun sum (xs)
(reduce #’+ xs))

you can write a (numerically unstable) ‘mean’ using ‘fork’.

(fork #’/ #’sum #’length)
(funcall * ’(1.0 2.0 3.0 4.0))
=> 2.5

From J.

Package

serapeum

Source

functions.lisp (file)

Function: fork2 G F H

Dyadic fork.

The dyadic fork of f, g, and h is defined as:

x (f g h) y <-> (x f y) g (x h y)

For example, say you wanted a "plus or minus" operator. Given numbers x and y, it returns a list of x+y and x-y. This can easily be written as a dyadic fork.

(fork2 #’list #’+ #’-)
(funcall * 10 2)
=> ’(12 8)

From J.

Package

serapeum

Source

functions.lisp (file)

Function: frequencies SEQ &rest HASH-TABLE-ARGS &key KEY &allow-other-keys

Return a hash table with the count of each unique item in SEQ. As a second value, return the length of SEQ.

From Clojure.

Package

serapeum

Source

sequences.lisp (file)

Function: front QUEUE

The first element in QUEUE.

Package

serapeum

Source

queue.lisp (file)

Function: gcp SEQS &key TEST

The greatest common prefix of SEQS.

If there is no common prefix, return NIL.

Package

serapeum

Source

sequences.lisp (file)

Function: gcs SEQS &key TEST

The greatest common suffix of SEQS.

If there is no common suffix, return NIL.

Package

serapeum

Source

sequences.lisp (file)

Function: get-unix-time ()

The current time as a count of seconds from the Unix epoch.

Package

serapeum

Source

time.lisp (file)

Function: grow N BY

Increase N by a factor.

Package

serapeum

Source

numbers.lisp (file)

Function: halves SEQ &optional SPLIT

Return, as two values, the first and second halves of SEQ.
SPLIT designates where to split SEQ; it defaults to half the length, but can be specified.

If SPLIT is not provided, the length is halved using ‘ceiling’ rather than ‘truncate’. This is on the theory that, if SEQ is a single-element list, it should be returned unchanged.

If SPLIT is negative, then the split is determined by counting |split| elements from the right (or, equivalently, length+split elements from the left.

Package

serapeum

Source

sequences.lisp (file)

Function: hash-fold FN INIT HASH-TABLE

Reduce TABLE by calling FN with three values: a key from the hash table, its value, and the return value of the last call to FN. On the first call, INIT is supplied in place of the previous value.

From Guile.

Package

serapeum

Source

hash-tables.lisp (file)

Function: hash-table-function HASH-TABLE &key READ-ONLY STRICT KEY-TYPE VALUE-TYPE STRICT-TYPES

Return a function for accessing HASH-TABLE.

Calling the function with a single argument is equivalent to ‘gethash’ against a copy of HASH-TABLE at the time HASH-TABLE-FUNCTION was called.

(def x (make-hash-table))

(funcall (hash-table-function x) y)
≡ (gethash y x)

If READ-ONLY is nil, then calling the function with two arguments is equivalent to ‘(setf (gethash ...))’ against HASH-TABLE.

If STRICT is non-nil, then the function signals an error if it is called with a key that is not present in HASH-TABLE. This applies to setting keys, as well as looking them up.

The function is able to restrict what types are permitted as keys and values. If KEY-TYPE is specified, an error will be signaled if an attempt is made to get or set a key that does not satisfy KEY-TYPE. If VALUE-TYPE is specified, an error will be signaled if an attempt is made to set a value that does not satisfy VALUE-TYPE. However, the hash table provided is *not* checked to ensure that the existing pairings KEY-TYPE and VALUE-TYPE – not unless STRICT-TYPES is also specified.

Package

serapeum

Source

hash-tables.lisp (file)

Function: hash-table-predicate HASH-TABLE

Return a predicate for membership in HASH-TABLE.
The predicate returns the same two values as ‘gethash’, but in the opposite order.

Package

serapeum

Source

hash-tables.lisp (file)

Function: hash-table-set TABLE &key STRICT TEST KEY

Return the set denoted by TABLE.
Given STRICT, check that the table actually denotes a set.

Without STRICT, equivalent to ‘hash-table-values’.

Package

serapeum

Source

hash-tables.lisp (file)

Function: hook F G

Monadic hook.
From J.

The hook of f is defined as f(y,g(y)).

For example, you can use a hook to test whether a number is an integer, by asking whether it is equal to its own floor.

(hook #’= #’floor)
(funcall * 2.0)
=> T

AKA Schoenfinkel’s S combinator.

Package

serapeum

Source

functions.lisp (file)

Function: hook2 F G

Dyadic hook.

The usual (only?) example of a dyadic hook is an ‘hour’ function that takes an hour and a count of minutes and returns a fractional count of hours.

(hook2 #’+ (partial (flip #’/) 60))
(funcall * 3.0 15.0)
=> 3.25

From J.

Package

serapeum

Source

functions.lisp (file)

Function: href TABLE &rest KEYS

A concise way of doings lookups in (potentially nested) hash tables.

(href (dict :x 1) :x) => x
(href (dict :x (dict :y 2)) :x :y) => y

Package

serapeum

Source

hash-tables.lisp (file)

Writer

(setf href) (function)

Function: (setf href) VALUE TABLE &rest KEYS
Package

serapeum

Source

hash-tables.lisp (file)

Reader

href (function)

Function: href-default DEFAULT TABLE &rest KEYS

Like ‘href’, with a default.
As soon as one of KEYS fails to match, DEFAULT is returned.

Package

serapeum

Source

hash-tables.lisp (file)

Function: in X &rest ITEMS

Is X equal to any of ITEMS?

‘(in x xs...)‘ is always equivalent to ‘(and (member x xs :test equal) t)‘, but ‘in‘ can sometimes compile to more efficient code when the candidate matches are constant.

From Arc.

Package

serapeum

Source

lists.lisp (file)

Function: intersperse NEW-ELT SEQ

Return a sequence like SEQ, but with NEW-ELT inserted between each element.

Package

serapeum

Source

sequences.lisp (file)

Function: interval &key SECONDS MINUTES HOURS DAYS WEEKS MONTHS YEARS MONTH-DAYS YEAR-DAYS

A verbose but readable way of specifying intervals in seconds.

Intended as a more readable alternative to idioms
like (let ((day-in-seconds #.(* 24 60 60))) ...)

Has a compiler macro.

Package

serapeum

Source

time.lisp (file)

Function: juxt &rest FNS

Clojure’s ‘juxt’.

Return a function of one argument, which, in turn, returns a list where each element is the result of applying one of FNS to the argument.

It’s actually quite simple, but easier to demonstrate than to explain. The classic example is to use ‘juxt‘ to implement ‘partition‘:

(defalias partition* (juxt #’filter #’remove-if))
(partition* #’evenp ’(1 2 3 4 5 6 7 8 9 10))
=> ’((2 4 6 8 10) (1 3 5 7 9))

The general idea is that ‘juxt‘ takes things apart.

Package

serapeum

Source

functions.lisp (file)

Function: keep ITEM SEQ &rest ARGS &key TEST FROM-END KEY COUNT &allow-other-keys

Almost, but not quite, an alias for ‘remove‘ with ‘:test-not‘ instead of ‘:test‘.

The difference is the handling of COUNT. For keep, COUNT is the number of items to keep, not remove.

(remove ’x ’(x y x y x y) :count 2)
=> ’(y y x y)

(keep ’x ’(x y x y x y) :count 2)
=> ’(x x)

‘keep’ becomes useful with the KEY argument:

(keep ’x ((x 1) (y 2) (x 3)) :key #’car)
=> ’((x 1) (x 3))

Package

serapeum

Source

sequences.lisp (file)

Function: leaf-map ()

Call FN on each leaf of TREE.
Return a new tree possibly sharing structure with TREE.

Package

serapeum

Source

trees.lisp (file)

Function: leaf-walk ()

Call FUN on each leaf of TREE.

Package

serapeum

Source

trees.lisp (file)

Function: length< &rest SEQS

Is each length-designator in SEQS shorter than the next? A length designator may be a sequence or an integer.

Package

serapeum

Source

sequences.lisp (file)

Function: length<= &rest SEQS

Is each length-designator in SEQS as long or shorter than the next? A length designator may be a sequence or an integer.

Package

serapeum

Source

sequences.lisp (file)

Function: length> &rest SEQS

Is each length-designator in SEQS longer than the next? A length designator may be a sequence or an integer.

Package

serapeum

Source

sequences.lisp (file)

Function: length>= &rest SEQS

Is each length-designator in SEQS longer or as long as the next? A length designator may be a sequence or an integer.

Package

serapeum

Source

sequences.lisp (file)

Function: lines STRING

A list of lines in STRING.

Package

serapeum

Source

strings.lisp (file)

Function: longer X Y

Return the longer of X and Y.

If X and Y are of equal length, return X.

Package

serapeum

Source

sequences.lisp (file)

Function: longest SEQS

Return the longest seq in SEQS.

Package

serapeum

Source

sequences.lisp (file)

Function: make CLASS &rest INITARGS &key &allow-other-keys

Shorthand for ‘make-instance’. After Eulisp.

Package

serapeum

Source

clos.lisp (file)

Function: make-hash-table-function &rest ARGS &key &allow-other-keys

Call ‘hash-table-function’ on a fresh hash table. ARGS can be args to ‘hash-table-function’ or args to ‘make-hash-table’, as they are disjoint.

Package

serapeum

Source

hash-tables.lisp (file)

Function: make-octet-vector SIZE

Make an octet vector of SIZE elements.

Package

serapeum

Source

octets.lisp (file)

Function: map-tree ()

Walk FUN over TREE and build a tree from the results.

The new tree may share structure with the old tree.

(eq tree (map-tree #’identity tree)) => T

FUN can skip the current subtree with (throw TAG SUBTREE), in which case SUBTREE will be used as the value of the subtree.

Package

serapeum

Source

trees.lisp (file)

Function: mapcar-into FN LIST

Like (map-into list fn list).

From PAIP.

Package

serapeum

Source

lists.lisp (file)

Function: mapconcat FUN SEQ SEPARATOR &key STREAM

Build a string by mapping FUN over SEQ.
Separate each value with SEPARATOR.

Equivalent to
(reduce #’concat (intersperse SEP SEQ) :key FUN)
but more efficient.

STREAM can be used to specify a stream to write to. It is resolved like the first argument to ‘format’.

From Emacs Lisp.

Package

serapeum

Source

strings.lisp (file)

Function: maphash-return FN HASH-TABLE

Like MAPHASH, but collect and return the values from FN. From Zetalisp.

Package

serapeum

Source

hash-tables.lisp (file)

Function: mapply FN LIST &rest LISTS

‘mapply’ is a cousin of ‘mapcar’.

If you think of ‘mapcar’ as using ‘funcall’:

(mapcar #’- ’(1 2 3))
≅ (loop for item in ’(1 2 3)
collect (funcall #’- item))

Then ‘mapply’ does the same thing, but with ‘apply’ instead.

(loop for item in ’((1 2 3) (4 5 6))
collect (apply #’+ item))
=> (6 15)

(mapply #’+ ’((1 2 3) (4 5 6)))
=> (6 15)

In variadic use, ‘mapply’ acts as if ‘append’ had first been used:

(mapply #’+ xs ys)
≡ (mapply #’+ (mapcar #’append xs ys))

But the actual implementation is more efficient.

‘mapply’ can convert a list of two-element lists into an alist:

(mapply #’cons ’((x 1) (y 2))
=> ’((x . 1) (y . 2))

Package

serapeum

Source

lists.lisp (file)

Function: maybe-invoke-restart RESTART &rest VALUES

When RESTART is active, invoke it with VALUES.

Package

serapeum

Source

conditions.lisp (file)

Function: memq ()

Like (member ... :test #’eq). Should only be used for symbols.

Package

serapeum

Source

lists.lisp (file)

Function: merge-tables TABLE &rest TABLES

Merge TABLE and TABLES, working from left to right.
The resulting hash table has the same parameters as TABLE.

If the same key is present in two tables, the value from the rightmost table is used.

All of the tables being merged must have the same value for ‘hash-table-test’.

Clojure’s ‘merge’.

Package

serapeum

Source

hash-tables.lisp (file)

Function: mvfold FN SEQ &rest SEEDS

Like ‘reduce’ extended to multiple values.

Calling ‘mvfold’ with one seed is equivalent to ‘reduce’:

(mvfold fn xs seed) ≡ (reduce fn xs :initial-value seed)

However, you can also call ‘mvfold’ with multiple seeds:

(mvfold fn xs seed1 seed2 seed3 ...)

How is this useful? Consider extracting the minimum of a sequence:

(reduce #’min xs)

Or the maximum:

(reduce #’max xs)

But both?

(reduce (lambda (cons item)
(cons (min (car cons) item)
(max (cdr cons) item)))
xs
:initial-value (cons (elt xs 0) (elt xs 0)))

You can do this naturally with ‘mvfold’.

(mvfold (lambda (min max item)
(values (min item min)
(max item max)))
xs (elt xs 0) (elt xs 0))

In general ‘mvfold’ provides a functional idiom for “loops with book-keeping” where we might otherwise have to use recursion or explicit iteration.

Has a compiler macro that generates efficient code when the number of SEEDS is fixed at compile time (as it usually is).

Package

serapeum

Source

sequences.lisp (file)

Function: mvfoldr FN SEQ &rest SEEDS

Like ‘(reduce FN SEQ :from-end t)’ extended to multiple values. Cf. ‘mvfold’.

Package

serapeum

Source

sequences.lisp (file)

Function: no X

Another alias for ‘not’ and ‘null’.

From Arc.

Package

serapeum

Source

control-flow.lisp (file)

Function: nstring-invert-case STRING

Destructive version of ‘string-invert-case’.

Package

serapeum

Source

strings.lisp (file)

Function: nstring-upcase-initials STRING

Destructive version of ‘string-upcase-initials’.

Package

serapeum

Source

strings.lisp (file)

Function: nsubseq SEQ START &optional END

Return a subsequence that may share structure with SEQ.

Note that ‘nsubseq’ gets its aposematic leading ‘n’ not because it is itself destructive, but because, unlike ‘subseq’, destructive operations on the subsequence returned may mutate the original.

‘nsubseq’ also works with ‘setf’, with the same behavior as ‘replace’.

Package

serapeum

Source

sequences.lisp (file)

Writer

(setf nsubseq) (function)

Function: (setf nsubseq) VALUE SEQ START &optional END

Destructively set SEQ between START and END to VALUE. Uses ‘replace’ internally.

Package

serapeum

Source

sequences.lisp (file)

Reader

nsubseq (function)

Function: nth-arg N

Return a function that returns only its NTH argument, ignoring all others.

If you’ve ever caught yourself trying to do something like

(mapcar #’second xs ys)

then ‘nth-arg‘ is what you need.

If ‘hash-table-keys‘ were not already defined by Alexandria, you could define it thus:

(defun hash-table-keys (table)
(maphash-return (nth-arg 0) table))

Package

serapeum

Source

functions.lisp (file)

Function: nth-best N SEQ PRED &key KEY

Return the Nth-best element of SEQ under PRED.

Equivalent to

(elt (sort (copy-seq seq) pred) n)

Or even

(elt (bestn (1+ n) seq pred) n)

But uses a selection algorithm for better performance than either.

Package

serapeum

Source

sequences.lisp (file)

Function: nth-best! N SEQ PRED &key KEY

Destructive version of ‘nth-best’.
Note that this function requires that SEQ be a vector.

Package

serapeum

Source

sequences.lisp (file)

Function: nthrest N LIST

Alias for ‘nthcdr’.

Package

serapeum

Source

lists.lisp (file)

Function: nub SEQ &rest ARGS &key START END KEY TEST

Remove duplicates from SEQ, starting from the end. TEST defaults to ‘equal’.

From Haskell.

Package

serapeum

Source

sequences.lisp (file)

Function: occurs LEAF TREE &key KEY TEST

Is LEAF present in TREE?

Package

serapeum

Source

trees.lisp (file)

Function: occurs-if TEST TREE &key KEY

Is there a node (leaf or cons) in TREE that satisfies TEST?

Package

serapeum

Source

trees.lisp (file)

Function: octet-vector-p X

Is X an octet vector?

Package

serapeum

Source

octets.lisp (file)

Function: octet-vector= V1 V2 &key START1 END1 START2 END2

Like ‘string=’ for octet vectors.

Package

serapeum

Source

octets.lisp (file)

Function: octets N &key BIG-ENDIAN

Return N, an integer, as an octet vector. Defaults to little-endian order.

Package

serapeum

Source

octets.lisp (file)

Function: of-length LENGTH

Return a predicate that returns T when called on a sequence of length LENGTH.

(funcall (of-length 3) ’(1 2 3)) => t
(funcall (of-length 1) ’(1 2 3)) => nil

Package

serapeum

Source

sequences.lisp (file)

Function: once FN

Return a function that runs FN only once, caching the results forever.

Package

serapeum

Source

functions.lisp (file)

Function: ordering SEQ &key UNORDERED-TO-END FROM-END TEST KEY

Given a sequence, return a function that, when called with ‘sort’, restores the original order of the sequence.

That is, for any SEQ (without duplicates), it is always true that

(equal seq (sort (reshuffle seq) (ordering seq)))

FROM-END controls what to do in case of duplicates. If FROM-END is true, the last occurrence of each item is preserved; otherwise, only the first occurrence counts.

TEST controls identity; it should be a valid test for a hash table. If the items cannot be compared that way, you can use KEY to transform them.

UNORDERED-TO-END controls where to sort items that are not present in the original ordering. By default they are sorted first but, if UNORDERED-TO-END is true, they are sorted last. In either case, they are left in no particular order.

Package

serapeum

Source

sequences.lisp (file)

Function: pairhash KEYS DATA &optional HASH-TABLE

Like ‘pairlis’, but for a hash table.

Unlike ‘pairlis’, KEYS and DATA are only required to be sequences, not lists.

By default, the hash table returned uses ‘eql’ as its tests. If you want a different test, make the table yourself and pass it as the HASH-TABLE argument.

Package

serapeum

Source

hash-tables.lisp (file)

Function: parse-float STRING &key START END JUNK-ALLOWED TYPE

Parse STRING as a float of TYPE.

The type of the float is determined by, in order:
- TYPE, if it is supplied;
- The type specified in the exponent of the string;
- or ‘*read-default-float-format*’.

(parse-float "1.0") => 1.0s0
(parse-float "1.0d0") => 1.0d0
(parse-float "1.0s0" :type ’double-float) => 1.0d0

Of course you could just use ‘parse-number’, but sometimes only a float will do.

Package

serapeum

Source

numbers.lisp (file)

Function: parse-leading-keywords BODY

Given BODY, return two values: a list of the leading inline keyword arguments, and the rest of the body.

Inline keywords are like the keyword arguments to individual cases in ‘restart-case’.

Package

serapeum

Source

macro-tools.lisp (file)

Function: partial FN &rest ARGS

Partial application.

Unlike ‘alexandria:curry’, which is only inlined when you ask it to be, ‘partial’ is always inlined if possible.

From Clojure.

Package

serapeum

Source

functions.lisp (file)

Function: partition PRED SEQ &key START END KEY

Partition elements of SEQ into those for which PRED returns true and false.

Return two values, one with each sequence.

Exactly equivalent to:
(values (remove-if-not predicate seq) (remove-if predicate seq)) except it visits each element only once.

Note that ‘partition‘ is not just ‘assort‘ with an up-or-down predicate. ‘assort‘ returns its groupings in the order they occur in the sequence; ‘partition‘ always returns the “true” elements first.

(assort ’(1 2 3) :key #’evenp) => ((1 3) (2))
(partition #’evenp ’(1 2 3)) => (2), (1 3)

Package

serapeum

Source

sequences.lisp (file)

Function: partition-declarations XS DECLARATIONS &optional ENV

Split DECLARATIONS into those that do and do not apply to XS. Return two values, one with each set.

Both sets of declarations are returned in a form that can be spliced directly into Lisp code:

(locally ,@(partition-declarations vars decls) ...)

Package

serapeum

Source

macro-tools.lisp (file)

Function: partitions PREDS SEQ &key START END KEY

Generalized version of PARTITION.

PREDS is a list of predicates. For each predicate, ‘partitions’ returns a filtered copy of SEQ. As a second value, it returns an extra sequence of the items that do not match any predicate.

Items are assigned to the first predicate they match.

Package

serapeum

Source

sequences.lisp (file)

Function: path-join &rest PATHNAMES

Build a pathname by merging from right to left.
With ‘path-join’ you can pass the elements of the pathname being built in the order they appear in it:

(path-join (user-homedir-pathname) config-dir config-file)
≡ (uiop:merge-pathnames* config-file
(uiop:merge-pathnames* config-dir (user-homedir-pathname)))

Note that ‘path-join’ does not coerce the parts of the pathname into directories; you have to do that yourself.

(path-join "dir1" "dir2" "file") -> #p"file"
(path-join "dir1/" "dir2/" "file") -> #p"dir1/dir2/file"

Package

serapeum

Source

files.lisp (file)

Function: plist-keys PLIST

Return the keys of a plist.

Package

serapeum

Source

lists.lisp (file)

Function: plist-values PLIST

Return the values of a plist.

Package

serapeum

Source

lists.lisp (file)

Function: pophash KEY HASH-TABLE

Lookup KEY in HASH-TABLE, return its value, and remove it.

This is only a shorthand. It is not in itself thread-safe.

From Zetalisp.

Package

serapeum

Source

hash-tables.lisp (file)

Function: powerset SET

Return the powerset of SET. Uses a non-recursive algorithm.

Package

serapeum

Source

lists.lisp (file)

Function: proper-subtype-p SUBTYPE TYPE &optional ENV

Is SUBTYPE a proper subtype of TYPE?

This is, is it true that SUBTYPE is a subtype of TYPE, but not the same type?

Package

serapeum

Source

types.lisp (file)

Function: proper-supertype-p SUPERTYPE TYPE &optional ENV

Is SUPERTYPE a proper supertype of TYPE?

That is, is it true that every value of TYPE is also of type SUPERTYPE, but not every value of SUPERTYPE is of type TYPE?

Package

serapeum

Source

types.lisp (file)

Function: prune LEAF TREE &key KEY TEST

Remove LEAF from TREE wherever it occurs.

Package

serapeum

Source

trees.lisp (file)

Function: prune-if ()

Remove any atoms satisfying TEST from TREE.

Package

serapeum

Source

trees.lisp (file)

Function: qappend QUEUE LIST

Append the elements of LIST onto the end of QUEUE. Return the queue.

Package

serapeum

Source

queue.lisp (file)

Function: qconc QUEUE LIST

Destructively concatenate LIST onto the end of QUEUE. Return the queue.

Package

serapeum

Source

queue.lisp (file)

Function: qlen QUEUE

The number of items in QUEUE.

Package

serapeum

Source

queue.lisp (file)

Function: qlist QUEUE

A list of the items in QUEUE.

Package

serapeum

Source

queue.lisp (file)

Function: queue &rest INITIAL-CONTENTS

Build a new queue with INITIAL-CONTENTS.

Package

serapeum

Source

queue.lisp (file)

Function: queue-empty-p QUEUE

Is QUEUE empty?

Package

serapeum

Source

queue.lisp (file)

Function: queuep OBJECT

Test for a queue.

Package

serapeum

Source

queue.lisp (file)

Function: random-in-range LOW HIGH

Random number in the range [low,high).

LOW and HIGH are automatically swapped if HIGH is less than LOW.

Note that the value of LOW+HIGH may be greater than the range that can
be represented as a number in CL. E.g., you can generate a random double float with

(random-in-range most-negative-double-float most-positive-double-float)

even though (+ most-negative-double-float most-positive-double-float)
would cause a floating-point overflow.

From Zetalisp.

Package

serapeum

Source

numbers.lisp (file)

Function: range ()

Return a (possibly specialized) vector of real numbers, starting from START.

With three arguments, return the integers in the interval [start,end) whose difference from START is divisible by STEP.

START, STOP, and STEP can be any real number, except that if STOP is greater than START, STEP must be positive, and if START is greater
than STOP, STEP must be negative.

The vector returned has the smallest element type that can represent numbers in the given range. E.g. the range [0,256) will usually be represented by a vector of octets, while the range [-10.0,10.0) will
be represented by a vector of single floats. The exact representation, however, depends on your Lisp implementation.

STEP defaults to 1.

With two arguments, return all the steps in the interval [start,end).

With one argument, return all the steps in the interval [0,end).

Package

serapeum

Source

range.lisp (file)

Function: rassocar ITEM ALIST &rest ARGS &key &allow-other-keys

Like (car (rassoc ...))

Package

serapeum

Source

lists.lisp (file)

Function: read-eval-prefix OBJECT STREAM

A helper for making objects readable.

The obvious way to give an object a readable representation is to use the sharp-dot reader macro. However, methods are supposed to consult the values of ‘*print-readably*’ and ‘*read-eval*’ before doing so. This function takes care of that for you.

If ‘*print-readably*’ is false, return an empty string.

If ‘*print-readably*’ is true, and ‘*read-eval*’ is also true, return the string "#.".

If ‘*print-readably*’ is true, but ‘*read-eval*’ is not true, signal an error.

Package

serapeum

Source

defining-types.lisp (file)

Function: remove-hook NAME FN

Remove fn from the symbol value of NAME.

Package

serapeum

Source

hooks.lisp (file)

Function: repeat-sequence SEQ N

Return a sequence like SEQ, with the same content, but repeated N times.

(repeat-sequence "13" 3)
=> "131313"

The length of the sequence returned will always be the length of SEQ times N.

This means that 0 repetitions results in an empty sequence:

(repeat-sequence "13" 0)
=> ""

Conversely, N may be greater than the possible length of a sequence, as long as SEQ is empty.

(repeat-sequence "" (1+ array-dimension-limit))
=> ""

Package

serapeum

Source

sequences.lisp (file)

Function: reshuffle SEQ &key ELEMENT-TYPE

Like ‘alexandria:shuffle’, but non-destructive.

Regardless of the type of SEQ, the return value is always a vector.

If ELEMENT-TYPE is provided, this is the element type (modulo upgrading) of the vector returned.

If ELEMENT-TYPE is not provided, then the element type of the vector returned is T, if SEQ is not a vector. If SEQ is a vector, then the element type of the vector returned is the same as the as the element type of SEQ.

Package

serapeum

Source

sequences.lisp (file)

Function: round-to NUMBER &optional DIVISOR

Like ‘round’, but return the resulting number.

(round 15 10) => 2
(round-to 15 10) => 20

Package

serapeum

Source

numbers.lisp (file)

Function: run-hook-with-args *HOOK* &rest ARGS

Apply each function in the symbol value of HOOK to ARGS.

Package

serapeum

Source

hooks.lisp (file)

Function: run-hook-with-args-until-failure *HOOK* &rest ARGS

Like ‘run-hook-with-args’, but quit once a function returns nil.

Package

serapeum

Source

hooks.lisp (file)

Function: run-hook-with-args-until-success *HOOK* &rest ARGS

Like ‘run-hook-with-args’, but quit once a function returns non-nil.

Package

serapeum

Source

hooks.lisp (file)

Function: run-hooks &rest HOOKVARS

Run all the hooks in all the HOOKVARS.
The variable ‘*hook*’ is bound to the name of each hook as it is being run.

Package

serapeum

Source

hooks.lisp (file)

Function: runs SEQ &key START END KEY TEST

Return a list of runs of similar elements in SEQ. The arguments START, END, and KEY are as for ‘reduce’.

(runs ’(head tail head head tail))
=> ’((head) (tail) (head head) (tail))

Package

serapeum

Source

sequences.lisp (file)

Function: same-case-p STRING

Every character with case in STRING has the same case. Return ‘:upper’ or ‘:lower’ as appropriate.

Package

serapeum

Source

strings.lisp (file)

Function: scan FN SEQ &key KEY INITIAL-VALUE

A version of ‘reduce’ that shows its work.

Instead of returning just the final result, ‘scan’ returns a sequence of the successive results at each step.

(reduce #’+ ’(1 2 3 4))
=> 10

(scan #’+ ’(1 2 3 4))
=> ’(1 3 6 10)

From APL and descendants.

Package

serapeum

Source

sequences.lisp (file)

Function: seq= &rest XS

Like ‘equal’, but recursively compare sequences element-by-element.

Two elements X and Y are ‘seq=’ if they are ‘equal’, or if they are both sequences of the same length and their elements are all ‘seq=’.

Package

serapeum

Source

sequences.lisp (file)

Function: set-hash-table SET &rest HASH-TABLE-ARGS &key TEST KEY STRICT &allow-other-keys

Return SET, a list considered as a set, as a hash table.
This is the equivalent of Alexandria’s ‘alist-hash-table’ and ‘plist-hash-table’ for a list that denotes a set.

STRICT determines whether to check that the list actually is a set.

The resulting hash table has the elements of SET for both its keys and values. That is, each element of SET is stored as if by
(setf (gethash (key element) table) element)

Package

serapeum

Source

hash-tables.lisp (file)

Function: shrink N BY

Decrease N by a factor.

Package

serapeum

Source

numbers.lisp (file)

Function: single SEQ

Is SEQ a sequence of one element?

Package

serapeum

Source

sequences.lisp (file)

Function: slice SEQ START &optional END

Like ‘subseq’, but allows negative bounds to specify offsets.
Both START and END accept negative bounds.

(slice "string" -3 -1) => "in"

Setf of ‘slice’ is like setf of ‘ldb’: afterwards, the place being set holds a new sequence which is not EQ to the old.

Package

serapeum

Source

sequences.lisp (file)

Setf Expander

(setf slice) (setf expander)

Setf Expander: (setf slice) SEQUENCE START &optional END
Package

serapeum

Source

sequences.lisp (file)

Reader

slice (function)

Function: sort-new SEQ PRED &key KEY ELEMENT-TYPE

Return a sorted vector of the elements of SEQ.

You can think of this as a non-destructive version of ‘sort’, except that it always returns a vector. (If you’re going to copy a sequence for the express purpose of sorting it, you might as well copy it into a form that can be sorted efficiently.)

ELEMENT-TYPE is interpreted as for ‘reshuffle’.

Package

serapeum

Source

sequences.lisp (file)

Function: stable-sort-new SEQ PRED &key KEY ELEMENT-TYPE

Like ‘sort-new’, but sort as if by ‘stable-sort’ instead of ‘sort’.

Package

serapeum

Source

sequences.lisp (file)

Function: string$= SUFFIX STRING &key START1 END1 START2 END2

Is SUFFIX a suffix of STRING?

Package

serapeum

Source

strings.lisp (file)

Function: string*= SUBSTRING STRING &key START1 END1 START2 END2

Is SUBSTRING a substring of STRING?

This is similar, but not identical, to SEARCH.

(search nil "foo") => 0
(search "nil" "nil") => 0
(string*= nil "foo") => NIL
(string*= nil "nil") => T

Package

serapeum

Source

strings.lisp (file)

Function: string+ &rest ARGS

Optimized function for building small strings.

Roughly equivalent to

(let ((*print-pretty* nil))
(format nil "~@{~a}" args...))

But with a compiler macro that can sometimes result in more efficient code.

Package

serapeum

Source

strings.lisp (file)

Function: string-contains-p SUBSTRING STRING &key START1 END1 START2 END2

Like ‘string*=’, but case-insensitive.

Package

serapeum

Source

strings.lisp (file)

Function: string-count SUBSTRING STRING &key START END

Count how many times SUBSTRING appears in STRING.

Package

serapeum

Source

strings.lisp (file)

Function: string-gensym X

Equivalent to (gensym (string x)).

Generally preferable to calling GENSYM with a string, because it respects the current read table.

The alternative to writing ‘(mapcar (compose #’gensym #’string) ...)’ in every other macro.

Package

serapeum

Source

macro-tools.lisp (file)

Function: string-invert-case STRING

Invert the case of STRING.
This does the same thing as a case-inverting readtable.

Package

serapeum

Source

strings.lisp (file)

Function: string-join STRINGS &optional SEPARATOR

Like ‘(mapconcat #’string STRINGS (string SEPARATOR))’.

Package

serapeum

Source

strings.lisp (file)

Function: string-prefix-p PREFIX STRING &key START1 END1 START2 END2

Like ‘string^=’, but case-insensitive.

Package

serapeum

Source

strings.lisp (file)

Function: string-replace OLD STRING NEW &key START END STREAM

Like ‘string-replace-all’, but only replace the first match.

Package

serapeum

Source

strings.lisp (file)

Function: string-replace-all OLD STRING NEW &key START END STREAM COUNT

Do search-and-replace for constant strings.

Note that START and END only affect where the replacements are made: the part of the string before START, and the part after END, are always included verbatim.

(string-replace-all "old" "The old old way" "new"
:start 3 :end 6)
=> "The new old way"

COUNT can be used to limit the maximum number of occurrences to replace. If COUNT is not specified, every occurrence of OLD between START and END is replaced with NEW.

(string-replace-all "foo" "foo foo foo" "quux")
=> "quux quux quux"

(string-replace-all "foo" "foo foo foo" "quux" :count 2)
=> "quux quux foo"

STREAM can be used to specify a stream to write to. It is resolved like the first argument to ‘format’.

Package

serapeum

Source

strings.lisp (file)

Function: string-suffix-p SUFFIX STRING &key START1 END1 START2 END2

Like ‘string$=’, but case-insensitive.

Package

serapeum

Source

strings.lisp (file)

Function: string-token-p TOKEN STRING &key START1 END1 START2 END2

Like ‘string~=’, but case-insensitive.

Package

serapeum

Source

strings.lisp (file)

Function: string-upcase-initials STRING

Return STRING with the first letter of each word capitalized. This differs from STRING-CAPITALIZE in that the other characters in each word are not changed.

(string-capitalize "an ACRONYM") -> "An Acronym") (string-upcase-initials "an ACRONYM") -> "An ACRONYM")

From Emacs Lisp (where it is simply ‘upcase-initials’).

Package

serapeum

Source

strings.lisp (file)

Function: string^= PREFIX STRING &key START1 END1 START2 END2

Is PREFIX a prefix of STRING?

Package

serapeum

Source

strings.lisp (file)

Function: string~= TOKEN STRING &key START1 END1 START2 END2

Does TOKEN occur in STRING as a token?

Equivalent to
(find TOKEN (tokens STRING) :test #’string=), but without consing.

Package

serapeum

Source

strings.lisp (file)

Function: supertypep SUPERTYPE TYPE &optional ENV

Is SUPERTYPE a supertype of TYPE? That is, is TYPE a subtype of SUPERTYPE?

Package

serapeum

Source

types.lisp (file)

Function: swaphash KEY VALUE HASH-TABLE

Set KEY and VALUE in HASH-TABLE, returning the old values of KEY.

This is only a shorthand. It is not in itself thread-safe.

From Zetalisp.

Package

serapeum

Source

hash-tables.lisp (file)

Function: take N SEQ

Return, at most, the first N elements of SEQ, as a *new* sequence of the same type as SEQ.

If N is longer than SEQ, SEQ is simply copied.

If N is negative, then |N| elements are taken (in their original order) from the end of SEQ.

Package

serapeum

Source

sequences.lisp (file)

Function: take-while PRED SEQ

Return the prefix of SEQ for which PRED returns true.

Package

serapeum

Source

sequences.lisp (file)

Function: throttle FN WAIT &key SYNCHRONIZED MEMOIZED

Wrap FN so it can be called no more than every WAIT seconds.
If FN was called less than WAIT seconds ago, return the values from the last call. Otherwise, call FN normally and update the cached values.

WAIT, of course, may be a fractional number of seconds.

The throttled function is not thread-safe by default; use SYNCHRONIZED to get a version with a lock.

You can pass MEMOIZED if you want the function to remember values between calls.

Package

serapeum

Source

functions.lisp (file)

Function: time-since TIME

Return seconds since TIME.

Package

serapeum

Source

time.lisp (file)

Function: time-until TIME

Return seconds until TIME.

Package

serapeum

Source

time.lisp (file)

Function: tokens STRING &key START END

Separate STRING into tokens.
Tokens are runs of non-whitespace characters.

(tokens "\"I’m here,\" Tom said presently.") => ("\"I’m" "here,\"" "Tom" "said" "presently.")

Cf. ‘words’.

Package

serapeum

Source

strings.lisp (file)

Function: toposort CONSTRAINTS &key TEST TIE-BREAKER FROM-END UNORDERED-TO-END

Turn CONSTRAINTS into a predicate for use with SORT.

Each constraint should be two-element list, where the first element of the list should come before the second element of the list.

(def dem-bones ’((toe foot)
(foot heel)
(heel ankle)
(ankle shin)
(shin knee)
(knee back)
(back shoulder)
(shoulder neck)
(neck head)))
(sort (reshuffle (mapcar #’car dem-bones))
(toposort dem-bones))
=> (TOE FOOT HEEL ANKLE SHIN KNEE BACK SHOULDER NECK)

If the graph is inconsistent, signals an error of type ‘inconsistent-graph‘:

(toposort ’((chicken egg) (egg chicken)))
=> Inconsistent graph: ((CHICKEN EGG) (EGG CHICKEN))

TEST, FROM-END, and UNORDERED-TO-END are passed through to ‘ordering’.

Package

serapeum

Source

sequences.lisp (file)

Function: trampoline FN &rest ARGS

Use the trampoline technique to simulate mutually recursive functions.

Call FN with supplied ARGS, if any.

If FN returns a functions, call that function with no arguments. Repeat until the return value is not a function, and finally return that non-function value.

Note that, to return a function as a final value, you must wrap it in some data structure and unpack it.

Most likely to be useful for Lisp implementations that do not provide tail call elimination.

From Clojure.

Package

serapeum

Source

functions.lisp (file)

Function: trim-whitespace STRING

STRING without whitespace at ends.

Package

serapeum

Source

strings.lisp (file)

Function: true X

Coerce X to a boolean.
That is, if X is null, return ‘nil’; otherwise return ‘t’.

Based on an idea by Eric Naggum.

Package

serapeum

Source

types.lisp (file)

Function: unbits BITS &key BIG-ENDIAN

Turn a sequence of BITS into an integer. Defaults to little-endian.

Package

serapeum

Source

numbers.lisp (file)

Function: unbox X

The value in the box X.

Package

serapeum

Source

box.lisp (file)

Writer

(setf unbox) (function)

Function: (setf unbox) VALUE X

Put VALUE in box X.

Package

serapeum

Source

box.lisp (file)

Reader

unbox (function)

Function: undisplace-array ARRAY

Recursively get the fundamental array that ARRAY is displaced to.

Return the fundamental array, and the start and end positions into it.

Borrowed from Erik Naggum.

Package

serapeum

Source

arrays.lisp (file)

Function: unique-name X

Alias for ‘string-gensym’.

Package

serapeum

Source

macro-tools.lisp (file)

Function: universal-to-unix TIME

Convert a universal time to a Unix time.

Package

serapeum

Source

time.lisp (file)

Function: unix-to-universal TIME

Convert a Unix time to a universal time.

Package

serapeum

Source

time.lisp (file)

Function: unoctets BYTES &key BIG-ENDIAN

Concatenate BYTES, an octet vector, into an integer. Defaults to little-endian order.

Package

serapeum

Source

octets.lisp (file)

Function: unsplice FORM

If FORM is non-nil, wrap it in a list.

This is useful with ,@ in macros, and with ‘mapcan’.

E.g., instead of writing:

‘(.... ,@(when flag ’((code))))

You can write:

‘(.... ,@(unsplice (when flag ’(code))))

From Lparallel.

Package

serapeum

Source

macro-tools.lisp (file)

Function: vect &rest INITIAL-CONTENTS

Succinct constructor for adjustable vectors with fill pointers.

(vect 1 2 3)
≡ (make-array 3
:adjustable t
:fill-pointer 3
:initial-contents (list 1 2 3))

The fill pointer is placed after the last element in INITIAL-CONTENTS.

Package

serapeum

Source

vectors.lisp (file)

Function: vector= VEC1 VEC2 &key TEST START1 START2 END1 END2

Like ‘string=’ for any vector.
If no TEST is supplied, elements are tested with ‘eql’.

Package

serapeum

Source

vector=.lisp (file)

Function: walk-tree ()

Call FUN in turn over each atom and cons of TREE.

FUN can skip the current subtree with (throw TAG nil).

Package

serapeum

Source

trees.lisp (file)

Function: whitespacep CHAR

Is CHAR whitespace?

Spaces, tabs, any kind of line break, page breaks, and no-break spaces are considered whitespace.

Package

serapeum

Source

strings.lisp (file)

Function: word-wrap STRING &key COLUMN STREAM

Return a word-wrapped version of STRING that breaks at COLUMN.

Note that this is not a general-purpose word-wrapping routine like you would find in a text editor: in particular, any existing whitespace is removed.

Package

serapeum

Source

strings.lisp (file)

Function: words STRING &key START END

Split STRING into words.

The definition of a word is the same as that used by ‘string-capitalize’: a run of alphanumeric characters.

(words "Four score and seven years")
=> ("Four" "score" "and" "seven" "years")

(words "2 words")
=> ("2" "words")

(words "two_words")
=> ("two" "words")

(words "\"I’m here,\" Tom said presently.")
=> ("I" "m" "here" "Tom" "said" "presently")

Cf. ‘tokens’.

Package

serapeum

Source

strings.lisp (file)

Function: write-stream-into-file STREAM PATHNAME &key IF-EXISTS IF-DOES-NOT-EXIST

Read STREAM and write the contents into PATHNAME.

STREAM will be closed afterwards, so wrap it with ‘make-concatenated-stream’ if you want it left open.

Package

serapeum

Source

files.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.6 Generic functions

Generic Function: inconsistent-graph-constraints CONDITION

The constraints of an ‘inconsistent-graph’ error. Cf. ‘toposort’.

Package

serapeum

Methods
Method: inconsistent-graph-constraints (CONDITION inconsistent-graph)
Source

sequences.lisp (file)

Generic Function: monitor OBJECT

Return a unique lock associated with OBJECT.

Package

serapeum

Source

threads.lisp (file)

Methods
Method: monitor (SYNCHRONIZED synchronized)

automatically generated reader method

Method: monitor OBJECT
Method: monitor (OBJECT mutex)

Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.7 Method combinations

Long Method Combination: standard/context ()
Package

serapeum

Source

mop.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.8 Conditions

Condition: case-failure ()

A subtype of type-error specifically for case failures.

Package

serapeum

Source

macro-tools.lisp (file)

Direct superclasses

type-error (condition)

Condition: econd-failure ()

A failed ECOND form.

Package

serapeum

Source

control-flow.lisp (file)

Direct superclasses

error (condition)

Direct slots
Slot: tests
Initargs

:tests

Direct Default Initargs
InitargValue
:testsnil
Condition: inconsistent-graph ()

A graph that cannot be consistently sorted.

Package

serapeum

Source

sequences.lisp (file)

Direct superclasses

error (condition)

Direct methods

inconsistent-graph-constraints (method)

Direct slots
Slot: constraints

The offending constraints

Initargs

:constraints

Readers

inconsistent-graph-constraints (generic function)

Condition: letrec-restriction-violation ()

Violation of the letrec restriction.

The "letrec restriction" means that the expressions being bound in a ‘letrec’ cannot refer to the value of other bindings in the same ‘letrec’.

For ‘fbindrec’, the restriction applies everywhere. For ‘fbindrec*’, it only applies to functions not yet bound.

Package

serapeum

Source

fbind.lisp (file)

Direct superclasses

error (condition)

Direct methods
  • args-of (method)
  • args-of (method)
Direct slots
Slot: args
Initargs

:args

Readers

args-of (generic function)

Writers

(setf args-of) (generic function)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.9 Structures

Structure: box ()

A box is just a mutable cell.

You create a box using ‘box’ and get and set its value using the accessor ‘unbox’.

(def a-box (box t))
(unbox a-box) => t
(setf (unbox a-box) nil)
(unbox a-box) => nil

At the moment, boxes are implemented as structures, but that may change. In particular, you should not depend on being able to recognize boxes using a type or predicate.

Package

serapeum

Source

box.lisp (file)

Direct superclasses

structure-object (structure)

Direct methods
  • make-load-form (method)
  • print-object (method)
Direct slots
Slot: value
Readers

box-value (function)

Writers

(setf box-value) (function)

Structure: queue ()

Basic cons queues, with an implementation based on PAIP and the original Norvig & Waters paper, and an API mostly borrowed from Arc.

About Arc. For the most part, Arc-style identifiers are pessimal, neither quite opaque nor quite explicit, like riddles. But by using abbreviated names, we avoid the danger of clashing with special-purpose queue implementations.

Create a queue with ‘queue’, like ‘list’:

(queue 1 2 3) => #<QUEUE (1 2 3)>

Get the items with ‘qlist’:

(qlist (queue 1 2 3)) => ’(1 2 3)

Add items with ‘enq’:

(enq 3 (queue 1 2)) => #<QUEUE (1 2 3)>

Remove an item with ‘deq’:

(deq (queue 1 2 3)) => 3

To (destructively) join a list to the end of the queue, use ‘qconc’:

(qconc (queue 1 2 3) ’(4 5 6)) => #<QUEUE (1 2 3 4 5 6)>

The rest of the API:

- ‘queuep’ Test for a queue
- ‘qlen’ Like ‘(length (qlist ...))’
- ‘clear-queue’ Clear the queue
- ‘front’ Like to ‘(car (qlist ...))’
- ‘queue-empty-p’ Test if the queue is empty
- ‘qappend’ Non-destructively join a list to the end of the queue

The idea is that *collecting* is something we do often enough to justifying making *collectors* (queues) first-class.

Package

serapeum

Source

queue.lisp (file)

Direct superclasses

structure-object (structure)

Direct methods
  • make-load-form (method)
  • print-object (method)
Direct slots
Slot: cons
Type

cons

Initform

(error "no cons!")

Readers

queue-cons (function)

Writers

(setf queue-cons) (function)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.10 Classes

Class: synchronized ()

Mixin for a class with its own monitor.

Package

serapeum

Source

threads.lisp (file)

Direct superclasses

standard-object (class)

Direct methods

monitor (method)

Direct slots
Slot: monitor
Initform

(bordeaux-threads:make-recursive-lock)

Readers

monitor (generic function)

Class: topmost-object-class ()
Package

serapeum

Source

mop.lisp (file)

Direct superclasses

standard-class (class)

Direct subclasses

unit-class (class)

Direct methods
  • reinitialize-instance (method)
  • initialize-instance (method)
  • validate-superclass (method)
  • print-object (method)
  • topmost-class (method)
Direct slots
Slot: topmost-class
Type

symbol

Initargs

:topmost-class

Readers

topmost-class (generic function)


Previous: , Up: Exported definitions   [Contents][Index]

6.1.11 Types

Type: -> ARGS VALUES

The type of a function from ARGS to VALUES.

Package

serapeum

Source

types.lisp (file)

Type: assure TYPE-SPEC
Package

serapeum

Source

types.lisp (file)

Type: input-stream ()
Package

serapeum

Source

types.lisp (file)

Type: octet ()
Package

serapeum

Source

types.lisp (file)

Type: octet-vector &optional LENGTH

An array of octets.

Package

serapeum

Source

types.lisp (file)

Type: output-stream ()
Package

serapeum

Source

types.lisp (file)

Type: tuple &rest TYPES

A proper list where each element has the same type as the corresponding element in TYPES.

(typep ’(1 :x #c) ’(tuple integer keyword character)) => T

As a shortcut, a quoted form among TYPES is expanded to an ‘eql’ type specifier. (tuple ’function symbol)
≡ (tuple (eql function) symbol)

The same shortcut works for keywords.
(tuple :name symbol)
≡ (tuple (eql :name) symbol)

Package

serapeum

Source

types.lisp (file)

Type: wholenum ()

A whole number. Equivalent to ‘(integer 0 *)’.

Package

serapeum

Source

types.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

6.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.1 Constants

Constant: +hash-table-default-size+
Package

serapeum

Source

hash-tables.lisp (file)

Constant: +lock-class+
Package

serapeum

Source

threads.lisp (file)

Constant: +seconds-in-day+
Package

serapeum

Source

time.lisp (file)

Constant: +seconds-in-hour+
Package

serapeum

Source

time.lisp (file)

Constant: +storage-for-deflex-var-no-bounds-checks+
Package

serapeum

Source

range.lisp (file)

Constant: +storage-for-deflex-var-no-break-space+
Package

serapeum

Source

strings.lisp (file)

Constant: +storage-for-deflex-var-octet-vector-class+
Package

serapeum/vector=

Source

vector=.lisp (file)

Constant: +storage-for-deflex-var-whitespace+

Whitespace characters.

Package

serapeum

Source

strings.lisp (file)

Constant: +unix-epoch+

The Unix epoch as a universal time.

Package

serapeum

Source

time.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.2 Special variables

Special Variable: *lexenv*

The environment of the macro being expanded.

Package

serapeum

Source

fbind.lisp (file)

Special Variable: *monitors*
Package

serapeum

Source

threads.lisp (file)

Special Variable: *subenv*
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Special Variable: *vref-by-type*
Package

serapeum

Source

types.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.3 Symbol macros

Symbol Macro: no-bounds-checks
Package

serapeum

Source

range.lisp (file)

Expansion

serapeum::+storage-for-deflex-var-no-bounds-checks+

Symbol Macro: no-break-space
Package

serapeum

Source

strings.lisp (file)

Expansion

serapeum::+storage-for-deflex-var-no-break-space+

Symbol Macro: octet-vector-class
Package

serapeum/vector=

Source

vector=.lisp (file)

Expansion

serapeum/vector=::+storage-for-deflex-var-octet-vector-class+

Symbol Macro: rest-arg
Package

serapeum/op

Source

op.lisp (file)

Expansion

(quote serapeum/op::_*)

Symbol Macro: sorting-networks
Package

serapeum

Source

control-flow.lisp (file)

Expansion

serapeum::*storage-for-deflex-var-sorting-networks*

Symbol Macro: test/=
Package

serapeum/vector=

Source

vector=.lisp (file)

Expansion

serapeum/vector=::*storage-for-deflex-var-test/=*

Symbol Macro: test/char-equal
Package

serapeum/vector=

Source

vector=.lisp (file)

Expansion

serapeum/vector=::*storage-for-deflex-var-test/char-equal*

Symbol Macro: test/char=
Package

serapeum/vector=

Source

vector=.lisp (file)

Expansion

serapeum/vector=::*storage-for-deflex-var-test/char=*

Symbol Macro: test/eq
Package

serapeum/vector=

Source

vector=.lisp (file)

Expansion

serapeum/vector=::*storage-for-deflex-var-test/eq*

Symbol Macro: test/eql
Package

serapeum/vector=

Source

vector=.lisp (file)

Expansion

serapeum/vector=::*storage-for-deflex-var-test/eql*

Symbol Macro: test/equal
Package

serapeum/vector=

Source

vector=.lisp (file)

Expansion

serapeum/vector=::*storage-for-deflex-var-test/equal*

Symbol Macro: test/equalp
Package

serapeum/vector=

Source

vector=.lisp (file)

Expansion

serapeum/vector=::*storage-for-deflex-var-test/equalp*

Symbol Macro: underscore
Package

serapeum/op

Source

op.lisp (file)

Expansion

(quote serapeum/op::_)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.4 Macros

Macro: %do-each (VAR SEQ &optional RETURN) &body BODY

Only for Lisps that do not support extensible sequences.

Package

serapeum

Source

sequences.lisp (file)

Macro: _once FN
Package

serapeum

Source

functions.lisp (file)

Macro: char-case-1 KEYFORM &body CLAUSES
Package

serapeum

Source

tree-case.lisp (file)

Macro: char-ecase-1 KEYFORM &body CLAUSES
Package

serapeum

Source

tree-case.lisp (file)

Macro: check-range/inline START STOP STEP
Package

serapeum

Source

range.lisp (file)

Macro: collecting* &body BODY

Intern COLLECT in the current package and bind it as a collector with MACROLET.

Package

serapeum

Source

iter.lisp (file)

Macro: declaim-constant-function &rest FNS

Declare that FNs are constant functions, for the benefit of Lisps that understand such declarations.

Package

serapeum

Source

types.lisp (file)

Macro: declaim-freeze-type &rest TYPES

Declare that TYPES is not going to change.

On Lisps that understand it, this is roughly equivalent to "sealing" a type in an OOP language: a promise that the type will never have any new subtypes, so tests for the type can be open-coded.

Package

serapeum

Source

types.lisp (file)

Macro: declaim-freeze-type-1 TYPE
Package

serapeum

Source

types.lisp (file)

Macro: declaim-maybe-inline &rest FNS
Package

serapeum

Source

macro-tools.lisp (file)

Macro: declaim-maybe-inline-1 FN
Package

serapeum

Source

macro-tools.lisp (file)

Macro: define-real-range NAME &body &key
Package

serapeum

Source

range.lisp (file)

Macro: define-variadic-equality VARIADIC BINARY
Package

serapeum

Source

control-flow.lisp (file)

Macro: dispatch-case/nobindings VARS-AND-TYPES &body CLAUSES
Package

serapeum/dispatch-case

Source

dispatch-case.lisp (file)

Macro: do-subseq (VAR SEQ &optional RETURN &key START END FROM-END) &body BODY
Package

serapeum

Source

sequences.lisp (file)

Macro: do-vector (VAR VEC &optional RETURN) &body BODY

Iterate over the items of a vector in a manner similar to ‘dolist’.

Package

serapeum

Source

sequences.lisp (file)

Macro: ensuring-functions VARS &body BODY
Package

serapeum

Source

macro-tools.lisp (file)

Macro: etypecase-of/no-shadows TYPE EXPR &body CLAUSES

Like ‘etypecase-of’, but filter shadowed clauses.

Package

serapeum/dispatch-case

Source

dispatch-case.lisp (file)

Macro: firstn-values N EXPR
Package

serapeum

Source

binding.lisp (file)

Macro: flet* BINDINGS &body BODY
Package

serapeum

Source

binding.lisp (file)

Macro: let-initialized BINDINGS &body BODY

Like LET, but if any of BINDINGS are uninitialized, try to give them sane initialization values.

Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Macro: mvdef VARS &body &optional
Package

serapeum

Source

definitions.lisp (file)

Macro: op/no-walker &body BODY
Package

serapeum/op

Source

op.lisp (file)

Macro: policy-quality-in-env QUAL
Package

serapeum

Source

types.lisp (file)

Macro: read-only-var REAL-VAR &optional NAME
Setf Expander: (setf read-only-var) REAL-VAR &optional NAME
Package

serapeum

Source

macro-tools.lisp (file)

Macro: rebinding-functions BINDINGS &body BODY

Like ‘rebinding’, but specifically for functions.
The value being rebound will be wrapped in ‘ensure-function’.

Package

serapeum

Source

macro-tools.lisp (file)

Macro: seq-dispatch SEQ &body LIST-FORM

Efficiently dispatch on the type of SEQ.

Package

serapeum

Source

macro-tools.lisp (file)

Macro: sort-values/network PRED &rest VALUES
Package

serapeum

Source

control-flow.lisp (file)

Macro: sort-values/temp-vector PRED &rest VALUES
Package

serapeum

Source

control-flow.lisp (file)

Macro: stack-flet BINDINGS &body BODY
Package

serapeum

Source

binding.lisp (file)

Macro: truly-the TYPE &body EXPR
Package

serapeum

Source

types.lisp (file)

Macro: variable-type-in-env VAR
Package

serapeum

Source

types.lisp (file)

Macro: vector-dispatch VEC &body BIT-VECTOR-FORM

Efficiently dispatch on the type of VEC.
The first form provides special handling for bit vectors. The second form provides generic handling for all types of vectors.

Package

serapeum

Source

macro-tools.lisp (file)

Macro: with-boolean VAR &body BODY
Package

serapeum

Source

types.lisp (file)

Macro: with-bounds (START1 END1 START2 END2) BOUNDS &body BODY
Package

serapeum/vector=

Source

vector=.lisp (file)

Macro: with-hook-restart &body BODY
Package

serapeum

Source

hooks.lisp (file)

Macro: with-int-vector (VAR VECT) &body BODY
Package

serapeum

Source

range.lisp (file)

Macro: with-key-fn (KEY) &body BODY

Specialize BODY on the most common key functions.

Package

serapeum

Source

types.lisp (file)

Macro: with-nullable (VAR TYPE) &body BODY
Package

serapeum

Source

types.lisp (file)

Macro: with-read-only-var (VAR) &body BODY

Try to make VAR read-only within BODY.

That is, within BODY, VAR is bound as a symbol macro, which expands into a macro whose setf expander, in turn, is defined to signal an error.

This is not reliable, of course, but it may occasionally save you from shooting yourself in the foot by unwittingly using a macro that calls ‘setf’ on a variable.

Package

serapeum

Source

macro-tools.lisp (file)

Macro: with-syms SYMS &body BODY

Like ‘with-gensyms’, but binds SYMS in the current package.

Package

serapeum

Source

iter.lisp (file)

Macro: with-test-fn (TEST) &body BODY

Specialize BODY on the most common test functions.

Package

serapeum

Source

types.lisp (file)

Macro: with-type-declarations-trusted (&key) &body BODY
Package

serapeum

Source

types.lisp (file)

Macro: with-vref TYPE &body BODY
Package

serapeum

Source

types.lisp (file)

Macro: without-internal-definitions &body BODY
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Macro: wrong-type DATUM TYPE RESTART &body REPORT
Package

serapeum

Source

types.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.5 Compiler macros

Compiler Macro: count-range START &optional END BY
Package

serapeum

Source

range.lisp (file)

Compiler Macro: eqls X
Package

serapeum

Source

functions.lisp (file)

Compiler Macro: eqs X
Package

serapeum

Source

functions.lisp (file)

Compiler Macro: equals X
Package

serapeum

Source

functions.lisp (file)

Compiler Macro: require-type DATUM SPEC
Package

serapeum

Source

types.lisp (file)

Compiler Macro: require-type-for DATUM SPEC PLACE
Package

serapeum

Source

types.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.6 Functions

Function: %require-type ()
Package

serapeum

Source

types.lisp (file)

Function: %require-type-for ()
Package

serapeum

Source

types.lisp (file)

Function: analyze-fbinds BINDINGS LEXENV

Pull apart BINDINGS, looking for lambdas to lift.

Package

serapeum

Source

fbind.lisp (file)

Function: augment/block BLOCK &optional SUBENV
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: augment/funs FUNS &optional SUBENV
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: augment/macros MACROS &optional SUBENV
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: augment/symbol-macros SYMBOL-MACROS &optional SUBENV
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: augment/tags TAGS &optional SUBENV
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: augment/vars BINDS &optional SUBENV
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: bisect-left VEC ITEM PRED &key KEY

Return the index in VEC to insert ITEM and keep VEC sorted.

Package

serapeum

Source

sequences.lisp (file)

Function: body+vars BODY ENV
Package

serapeum/op

Source

op.lisp (file)

Function: body-decls BODY
Package

serapeum

Source

fbind.lisp (file)

Function: bounds START1 END1 START2 END2
Package

serapeum/vector=

Source

vector=.lisp (file)

Function: bounds-end1 INSTANCE
Package

serapeum/vector=

Source

vector=.lisp (file)

Function: bounds-end2 INSTANCE
Package

serapeum/vector=

Source

vector=.lisp (file)

Function: bounds-start1 INSTANCE
Package

serapeum/vector=

Source

vector=.lisp (file)

Function: bounds-start2 INSTANCE
Package

serapeum/vector=

Source

vector=.lisp (file)

Function: bounds-trivial? VEC START END
Package

serapeum/vector=

Source

vector=.lisp (file)

Function: box-value INSTANCE
Function: (setf box-value) VALUE INSTANCE
Package

serapeum

Source

box.lisp (file)

Function: boxp OBJECT
Package

serapeum

Source

box.lisp (file)

Function: branch-type BRANCH
Package

serapeum/dispatch-case

Source

dispatch-case.lisp (file)

Function: bucket-front SEQ BUCKET
Package

serapeum

Source

sequences.lisp (file)

Function: bucket-push SEQ ITEM BUCKET
Package

serapeum

Source

sequences.lisp (file)

Function: bucket-seq SEQ BUCKET
Package

serapeum

Source

sequences.lisp (file)

Function: build-bind/ftype FN VAR DECLS ENV

Return a form, suitable for the bindings of a ‘flet’ or ‘labels’ form, that binds a function named FN which calls the function in a variable named VAR.

If there is a declared ftype for FN in the decls-env combination, it may be used to make calling VAR more efficient by avoiding ‘apply’.

Package

serapeum

Source

fbind.lisp (file)

Function: call/string FN STREAM

Resolve STREAM like ‘format’ and call FN with the result.

Package

serapeum

Source

strings.lisp (file)

Function: canonicalize-bindings BINDINGS
Package

serapeum

Source

binding.lisp (file)

Function: canonicalize-key K
Package

serapeum

Source

sequences.lisp (file)

Function: canonicalize-test TEST &optional TEST-NOT
Package

serapeum

Source

sequences.lisp (file)

Function: check-exhaustiveness STYLE TYPE CLAUSES ENV
Package

serapeum

Source

control-flow.lisp (file)

Function: check-match-exhaustive UNION CLAUSES ENV
Package

serapeum

Source

defining-types.lisp (file)

Function: check-range START STOP STEP
Package

serapeum

Source

range.lisp (file)

Function: check-same-test HT1 HT2

Check that HT1 and HT2, two hash tables, have the same value for ‘hash-table-test’.

This should work even for "custom" hash tables with user-defined tests.

Package

serapeum

Source

hash-tables.lisp (file)

Function: clause-leading-type CLAUSE
Package

serapeum/dispatch-case

Source

dispatch-case.lisp (file)

Function: clauses+default CLAUSES &key DEFAULT-KEYS
Package

serapeum

Source

macro-tools.lisp (file)

Function: collect-fallthrough-clauses BRANCH MORE-BRANCHES &optional ENV

Collect fallthrough clauses from MORE-BRANCHES into BRANCH.

Package

serapeum/dispatch-case

Source

dispatch-case.lisp (file)

Function: constructor= X Y
Package

serapeum

Source

defining-types.lisp (file)

Function: copy-bounds BOUNDS &key START1 END1 START2 END2

Copy BOUNDS, optionally overriding some or all of its slots.

Package

serapeum/vector=

Source

vector=.lisp (file)

Function: copy-box INSTANCE
Package

serapeum

Source

box.lisp (file)

Function: copy-hash-table/empty TABLE &key TEST SIZE REHASH-SIZE REHASH-THRESHOLD

Make a hash table with the same parameters (test, size, &c.) as TABLE, but empty.

Package

serapeum

Source

hash-tables.lisp (file)

Function: copy-queue INSTANCE
Package

serapeum

Source

queue.lisp (file)

Function: copy-string X
Package

serapeum

Source

strings.lisp (file)

Function: copy-subenv SUBENV &key VARS FUNS BLOCKS TAGS
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: count-range START &optional END STEP

Return a vector of ascending positive integers.

With one argument, return all the integers in the interval [0,end).

With two arguments, return all the integers in the interval [start,end).

With three arguments, return the integers in the interval [start,end) whose difference from START is evenly divisible by STEP.

Package

serapeum

Source

range.lisp (file)

Function: count-range/1 ()
Package

serapeum

Source

range.lisp (file)

Function: count-range/2 ()
Package

serapeum

Source

range.lisp (file)

Function: count-range/3 ()
Package

serapeum

Source

range.lisp (file)

Function: declared-ftype FN DECLS &optional ENV

If DECLS contains an ftype declaration for FN, return it.
Returns three values. The first two values are the arguments type and return type. The third is a boolean, which is ‘t’ only when there was an ftype declaration.

Package

serapeum

Source

fbind.lisp (file)

Function: default-tie-breaker MIN-ELTS CONSTRAINTS

The default tie breaker for a topological sort.

Package

serapeum

Source

sequences.lisp (file)

Function: describe-non-exhaustive-match STREAM PARTITION TYPE ENV
Package

serapeum

Source

control-flow.lisp (file)

Function: double-float-range START STOP STEP
Package

serapeum

Source

range.lisp (file)

Function: ensure-monitor OBJECT STRING
Package

serapeum

Source

threads.lisp (file)

Function: ensure-subenv ()
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: ensure-var VAR
Package

serapeum/dispatch-case

Source

dispatch-case.lisp (file)

Function: eqls X

A predicate for equality (under EQL) with X.

Package

serapeum

Source

functions.lisp (file)

Function: eqs X

A predicate for equality (under EQ) with X.

Package

serapeum

Source

functions.lisp (file)

Function: equals X

A predicate for equality (under EQUAL) with X.

Package

serapeum

Source

functions.lisp (file)

Function: escape/no-arg-parsing ()
Package

serapeum

Source

strings.lisp (file)

Function: expand-binding BIND
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: expand-bindings BINDINGS
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: expand-case-macro CONT EXPR CLAUSES &key DEFAULT-KEYS ERROR MACRO-NAME
Package

serapeum

Source

macro-tools.lisp (file)

Function: expand-case-macro/common CLAUSES &key JUMP MACRO-NAME
Package

serapeum

Source

macro-tools.lisp (file)

Function: expand-case-macro/flet CONT EXPR-TEMP NORMAL-CLAUSES DEFAULT &key MACRO-NAME
Package

serapeum

Source

macro-tools.lisp (file)

Function: expand-case-macro/tagbody CONT EXPR-TEMP NORMAL-CLAUSES DEFAULT &key MACRO-NAME
Package

serapeum

Source

macro-tools.lisp (file)

Function: expand-char-case-keys CLAUSES
Package

serapeum

Source

tree-case.lisp (file)

Function: expand-destructuring-case-of TYPE KEY CLAUSES CASE-OF
Package

serapeum

Source

control-flow.lisp (file)

Function: expand-fbindings BINDINGS
Package

serapeum

Source

fbind.lisp (file)

Function: expand-href TABLE KEYS
Package

serapeum

Source

hash-tables.lisp (file)

Function: expand-mvfold FN SEQ SEEDS &optional FROM-END
Package

serapeum

Source

sequences.lisp (file)

Function: expand-read-only-var VAR ENV
Package

serapeum

Source

macro-tools.lisp (file)

Function: expand-variadic-equality BINARY VARIADIC ARGS
Package

serapeum

Source

control-flow.lisp (file)

Function: exponent-char-format EXPONENT-CHAR
Package

serapeum

Source

numbers.lisp (file)

Function: exponent-char? CHAR
Package

serapeum

Source

numbers.lisp (file)

Function: extract-function-name X

If possible, extract the name from X, a function designator.

Package

serapeum

Source

macro-tools.lisp (file)

Function: extract-op-env BODY ENV
Package

serapeum/op

Source

op.lisp (file)

Function: extract-tagbody-tags BODY
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: file=/loop ()

Compare two files by looping over their octets.

Package

serapeum

Source

files.lisp (file)

Function: fill-int-range! ()
Package

serapeum

Source

range.lisp (file)

Function: filter/counted PRED SEQ &rest ARGS &key COUNT FROM-END START END KEY

Helper for FILTER.

Package

serapeum

Source

sequences.lisp (file)

Function: filter/swapped-arguments SEQ PRED &rest ARGS &key &allow-other-keys
Package

serapeum

Source

sequences.lisp (file)

Function: format-econd-tests STREAM TESTS
Package

serapeum

Source

control-flow.lisp (file)

Function: frange START STOP STEP

Perform floating-point contagion on START, STOP, and STEP, and call ‘range’ on the results.

Package

serapeum

Source

range.lisp (file)

Function: free? X ENV
Package

serapeum/op

Source

op.lisp (file)

Function: fun NAME INIT
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: gensym? X

Is X a gensym’d (uninterned) symbol?

Package

serapeum

Source

fbind.lisp (file)

Function: heap-extract HEAP I &key KEY TEST
Package

serapeum

Source

sequences.lisp (file)

Function: heap-extract-all HEAP &key KEY TEST
Package

serapeum

Source

sequences.lisp (file)

Function: heap-extract-maximum HEAP &key KEY TEST
Package

serapeum

Source

sequences.lisp (file)

Function: heap-insert HEAP NEW-ITEM &key KEY TEST
Package

serapeum

Source

sequences.lisp (file)

Function: heap-left I
Package

serapeum

Source

sequences.lisp (file)

Function: heap-maximum HEAP
Package

serapeum

Source

sequences.lisp (file)

Function: heap-parent I
Package

serapeum

Source

sequences.lisp (file)

Function: heap-right I
Package

serapeum

Source

sequences.lisp (file)

Function: heapify HEAP START &key KEY TEST
Package

serapeum

Source

sequences.lisp (file)

Function: hoist-clause-bodies BLOCK CLAUSES ENV

Hoist the bodies of the clauses into tags.
This is needed because the same clause may be spliced into the dispatch-case form in several places (in order to implement fallthrough).

Returns two values: a list of alternating tags and forms, and a list of clauses rewritten to jump to the tags.

Package

serapeum/dispatch-case

Source

dispatch-case.lisp (file)

Function: ignored-functions-in-body BODY
Package

serapeum

Source

fbind.lisp (file)

Function: ignored-functions-in-decls DECLS
Package

serapeum

Source

fbind.lisp (file)

Function: initialize-binds-from-decls BINDS-IN DECLS &optional ENV

Given a list of bindings and a set of declarations, look for any uninitialized bindings. If there are any, try to extrapolate reasonable initialization values for them based on the declarations in DECLS.

Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: insert-superclass SUPERCLASS LIST
Package

serapeum/mop

Source

mop.lisp (file)

Function: int-range-shape START STOP STEP

Return the length and element type for a range vector from START to STOP by STEP.

Package

serapeum

Source

range.lisp (file)

Function: integer-range START STOP STEP
Package

serapeum

Source

range.lisp (file)

Function: intersperse/list NEW-ELT LIST
Package

serapeum

Source

sequences.lisp (file)

Function: intersperse/seq NEW-ELT SEQ
Package

serapeum

Source

sequences.lisp (file)

Function: invalid &rest ARGS
Package

serapeum

Source

fbind.lisp (file)

Function: key-test ()

Return a function of two arguments which uses KEY to extract the part of the arguments to compare, and compares them using TEST.

Package

serapeum

Source

sequences.lisp (file)

Function: lambda-list-vars LAMBDA-LIST

Return a list of the variables bound in LAMBDA-LIST, an ordinary lambda list.

Package

serapeum

Source

macro-tools.lisp (file)

Function: let-over-lambda ()

Expand form, using ‘expand-macro’. If the result is a simple let-over-lambda, analyze it into an environment, declarations, and a lambda.

Package

serapeum

Source

fbind.lisp (file)

Function: list+length LIST START END
Package

serapeum

Source

lists.lisp (file)

Function: list-map-from-end/bordeaux ()

Traverse LIST from the end, calling FUN on each item.

This uses the technique described by Durand and Strandh in their paper presented at ECLS 2015, “Processing List Elements in Reverse Order.”

Package

serapeum

Source

lists.lisp (file)

Function: list-runs LIST START END KEY TEST
Package

serapeum

Source

sequences.lisp (file)

Function: lock-form OBJECT OBJECTP ENV STRING
Package

serapeum

Source

threads.lisp (file)

Function: long-float-range START STOP STEP
Package

serapeum

Source

range.lisp (file)

Function: macro NAME INIT
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: make-bucket SEQ &optional INIT
Package

serapeum

Source

sequences.lisp (file)

Function: make-float NUMBER DIVISOR &optional FORMAT
Package

serapeum

Source

numbers.lisp (file)

Function: make-heap &optional SIZE
Package

serapeum

Source

sequences.lisp (file)

Function: make-op-env &rest ARGS &key &allow-other-keys
Package

serapeum/op

Source

op.lisp (file)

Function: make-queue &aux CONS
Package

serapeum

Source

queue.lisp (file)

Function: make-queue-cons ()
Package

serapeum

Source

queue.lisp (file)

Function: make-sequence-like SEQ LEN &rest ARGS &key INITIAL-ELEMENT INITIAL-CONTENTS

Helper function: make a sequence of length LEN having the same type as SEQ.

Package

serapeum

Source

sequences.lisp (file)

Function: make-unique-name-list LENGTH &optional X

Alias for ‘alexandria:make-gensym-list’.

Package

serapeum

Source

macro-tools.lisp (file)

Function: map-subseq ()

Helper function to map SEQ between START and END.

Package

serapeum

Source

sequences.lisp (file)

Function: mapconcat/list FUN LIST SEP STREAM
Package

serapeum

Source

strings.lisp (file)

Function: mapconcat/seq FUN SEQ SEP STREAM
Package

serapeum

Source

strings.lisp (file)

Function: merely-syntactic-functions NAMES BODY-WITH-DECLS ENV

Which functions in NAMES are merely syntactic?

Functions are "merely syntactic" if they are never dereferenced with ‘function’ (or sharp-quote).

This function may return false negatives – it may fail to detect that a function is syntactic – but it should never return a false positive – it should never say a function is syntactic when it is not.

Package

serapeum

Source

fbind.lisp (file)

Function: merge-tables! TABLE &rest TABLES
Package

serapeum

Source

hash-tables.lisp (file)

Function: mvfold-aux FN SEQ SEEDS &optional FROM-END
Package

serapeum

Source

sequences.lisp (file)

Function: newline? C
Package

serapeum

Source

strings.lisp (file)

Function: normalize-cases CASES &key ALLOW-DEFAULT

Normalize CASES, clauses for a case-like macro.
Return each non-default clause normalized to ‘(keys . body)’, where keys is a *list* of keys.

Return the default clause as a second value.

If there is more than one default clause, signal an error.

Package

serapeum

Source

macro-tools.lisp (file)

Function: numbered-placeholder? X ENV
Package

serapeum/op

Source

op.lisp (file)

Function: octet-vector=/unsafe ()
Package

serapeum

Source

octets.lisp (file)

Function: partition-declarations-by-kind SIMPLE COMPLEX LAMBDA DECLS
Package

serapeum

Source

fbind.lisp (file)

Function: partition-fbinds FBINDS BODY

Partition FBINDS using the "Fixing Letrec" algorithm.
Returns the bindings in four sets: unreferenced, literal lambdas, simple (external references) and complex (everything else).

BODY is needed because we detect unreferenced bindings by looking for ‘ignore’ declarations.

Package

serapeum

Source

fbind.lisp (file)

Function: pattern-type PATTERN UNION

Return two values: the type and the final pattern.

Package

serapeum

Source

defining-types.lisp (file)

Function: placeholder? X ENV
Package

serapeum/op

Source

op.lisp (file)

Function: prepare-int-range START STOP STEP
Package

serapeum

Source

range.lisp (file)

Function: print-constructor OBJECT STREAM FIELDS
Package

serapeum

Source

defining-types.lisp (file)

Function: queue-cons INSTANCE
Package

serapeum

Source

queue.lisp (file)

Function: quickselect ()

Hoare’s quickselect, as implemented by Wirth ("FIND"), with refinements by V. Zabrodsky ("MODIFIND").

Package

serapeum

Source

sequences.lisp (file)

Function: quotation? X ENV
Package

serapeum/op

Source

op.lisp (file)

Function: quote-unless-constant VALUE &optional ENV
Package

serapeum

Source

defining-types.lisp (file)

Function: range-error START STOP STEP
Package

serapeum

Source

range.lisp (file)

Function: read-float STREAM JUNK-ALLOWED TYPE
Package

serapeum

Source

numbers.lisp (file)

Function: read-float-aux ()
Package

serapeum

Source

numbers.lisp (file)

Function: read-new-value ()

Read and evaluate a value.

Package

serapeum

Source

types.lisp (file)

Function: read-only-include-clause CLAUSE

Rewrite CLAUSE, an include clause, for use with a read-only structure.

Package

serapeum

Source

defining-types.lisp (file)

Function: read-only-slotdef SLOT

Rewrite SLOT, a structure slot definition, to be read-only.
Note that if SLOT is of an odd length, then it is treated as being without an initialization form, and a default initialization form that raises an error is supplied.

Package

serapeum

Source

defining-types.lisp (file)

Function: real-range START STOP STEP
Package

serapeum

Source

range.lisp (file)

Function: reify-bounds VEC1 VEC2 START1 END1 START2 END2
Package

serapeum/vector=

Source

vector=.lisp (file)

Function: remove-duplicated-subtypes SUBTYPES
Package

serapeum

Source

types.lisp (file)

Function: remove-shadowed BINDS &optional SUBENV
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: remove-shadowed-clauses CLAUSES &optional ENV

Given a list of typecase clauses, remove any clauses that are shadowed by previous clauses.

Package

serapeum/dispatch-case

Source

dispatch-case.lisp (file)

Function: remove-shadowed-subtypes SUBTYPES
Package

serapeum

Source

types.lisp (file)

Function: repeat-list LIST N
Package

serapeum

Source

sequences.lisp (file)

Function: repeat-vector ()
Package

serapeum

Source

sequences.lisp (file)

Function: require-type ()
Package

serapeum

Source

types.lisp (file)

Function: require-type-for ()
Package

serapeum

Source

types.lisp (file)

Function: rest-op? ()
Package

serapeum/op

Source

op.lisp (file)

Function: rest-placeholder? X ENV
Package

serapeum/op

Source

op.lisp (file)

Function: reuse-cons X Y X-Y

If X and Y are the car and cdr of X-Y, return X-Y.

Otherwise, return a fresh cons of X and Y.

Package

serapeum

Source

trees.lisp (file)

Function: same-literal-p X Y

A predicate that compares whether X and Y have the same literal representation.

Package

serapeum

Source

definitions.lisp (file)

Function: same-test? HT1 HT2

Do two hash tables have the same test?

Package

serapeum

Source

hash-tables.lisp (file)

Function: same-type? TYPE1 TYPE2 &optional ENV

Like ‘alexandria:type=’, but takes an environment.

Package

serapeum

Source

control-flow.lisp (file)

Function: seq=/2 X Y
Package

serapeum

Source

sequences.lisp (file)

Function: sequence? X
Package

serapeum

Source

sequences.lisp (file)

Function: setslice SEQ1 SEQ2 START &optional END

Helper to ‘set’ a slice non-destructively.

Package

serapeum

Source

sequences.lisp (file)

Function: shadow-names BINDS
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: short-float-range START STOP STEP
Package

serapeum

Source

range.lisp (file)

Function: shortest SEQS

Return the shortest seq in SEQS.

Package

serapeum

Source

sequences.lisp (file)

Function: simple-binding-p BINDING
Package

serapeum

Source

binding.lisp (file)

Function: simple-lambda-list? LAMBDA-LIST

A lambda list with no inits.

Package

serapeum

Source

fbind.lisp (file)

Function: simplify-keylists CLAUSES

Simplify the keylists in CLAUSES.

If the keylist is an empty list, omit the clause.

If the keylist is a list with one element, unwrap that element.

Otherwise, leave the keylist alone.

Package

serapeum

Source

macro-tools.lisp (file)

Function: simplify-string STRING
Package

serapeum

Source

strings.lisp (file)

Function: simplify-string-plus-args ARGS
Package

serapeum

Source

strings.lisp (file)

Function: simplify-subtypes SUBTYPES
Package

serapeum

Source

types.lisp (file)

Function: single-float-range START STOP STEP
Package

serapeum

Source

range.lisp (file)

Function: slice-bounds LEN START END

Normalize START and END, which may be negative, to offsets acceptable to SUBSEQ.

Package

serapeum

Source

sequences.lisp (file)

Function: sort-clauses CLAUSES &optional ENV

Given a list of typecase clauses, order them so no preceding clause shadows later ones, if possible.

Package

serapeum/dispatch-case

Source

dispatch-case.lisp (file)

Function: sort-subtypes SUBTYPES
Package

serapeum

Source

types.lisp (file)

Function: sorting-network SIZE
Package

serapeum

Source

control-flow.lisp (file)

Function: space-beats-speed? ENV
Package

serapeum

Source

types.lisp (file)

Function: split-at LIST K
Package

serapeum

Source

sequences.lisp (file)

Function: string-case-failure EXPR KEYS
Package

serapeum

Source

control-flow.lisp (file)

Function: string-replace-all/no-arg-parsing OLD STRING NEW START END STREAM COUNT
Package

serapeum

Source

strings.lisp (file)

Function: subtypes-exhaustive? TYPE SUBTYPES &optional ENV
Package

serapeum

Source

types.lisp (file)

Function: sym-numbered-placeholder? X
Package

serapeum/op

Source

op.lisp (file)

Function: sym-rest-arg? X
Package

serapeum/op

Source

op.lisp (file)

Function: sym-underscore? X
Package

serapeum/op

Source

op.lisp (file)

Function: symbol-macro NAME INIT
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: symbol-macro-bindings &optional SUBENV
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: tagbody-tag? FORM
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: test-fn TEST
Package

serapeum/vector=

Source

vector=.lisp (file)

Function: test-kind TEST
Package

serapeum/vector=

Source

vector=.lisp (file)

Function: thread-aux THREADER NEEDLE HOLES THREAD-FN
Package

serapeum

Source

control-flow.lisp (file)

Function: tsort ELTS CONSTRAINTS TIE-BREAKER

Do the initial topological sort.

Package

serapeum

Source

sequences.lisp (file)

Function: type-vref TYPE
Package

serapeum

Source

types.lisp (file)

Function: unbound VAR
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: unbound-p OBJECT
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: unbound-var INSTANCE
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: var NAME INIT
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Function: var-lexical? X ENV
Package

serapeum/op

Source

op.lisp (file)

Function: vector-kind V
Package

serapeum/vector=

Source

vector=.lisp (file)

Function: visible-of-type TYPE SUBENV
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.7 Generic functions

Generic Function: %constructor= X Y
Package

serapeum

Source

defining-types.lisp (file)

Methods
Method: %constructor= (O1 bounds) (O2 bounds)
Source

vector=.lisp (file)

Method: %constructor= X Y
Generic Function: .blocks ENV
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Methods
Method: .blocks (SUBENV subenv)

automatically generated reader method

Method: .blocks (ENV null)
Generic Function: .funs ENV
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Methods
Method: .funs (SUBENV subenv)

automatically generated reader method

Method: .funs (ENV null)
Generic Function: .tags ENV
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Methods
Method: .tags (SUBENV subenv)

automatically generated reader method

Method: .tags (ENV null)
Generic Function: .vars ENV
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Methods
Method: .vars (SUBENV subenv)

automatically generated reader method

Method: .vars (ENV null)
Generic Function: alias-decls SELF DECLS
Package

serapeum/internal-definitions

Methods
Method: alias-decls (SELF internal-definitions-env) DECLS
Source

internal-definitions.lisp (file)

Generic Function: args-of CONDITION
Generic Function: (setf args-of) NEW-VALUE CONDITION
Package

serapeum

Methods
Method: args-of (CONDITION letrec-restriction-violation)
Method: (setf args-of) NEW-VALUE (CONDITION letrec-restriction-violation)
Source

fbind.lisp (file)

Generic Function: at-beginning? SELF
Package

serapeum/internal-definitions

Methods
Method: at-beginning? (SELF internal-definitions-env)

Return non-nil if this is the first form in the ‘local’.

Source

internal-definitions.lisp (file)

Generic Function: binding-init OBJECT
Package

serapeum/internal-definitions

Methods
Method: binding-init (%BINDING %binding)

automatically generated reader method

Source

internal-definitions.lisp (file)

Generic Function: binding-name OBJECT
Package

serapeum/internal-definitions

Methods
Method: binding-name (%BINDING %binding)

automatically generated reader method

Source

internal-definitions.lisp (file)

Generic Function: bounds-plausible? BOUNDS V1 V2
Package

serapeum/vector=

Source

vector=.lisp (file)

Methods
Method: bounds-plausible? (BOUNDS null) V1 V2
Method: bounds-plausible? (BOUNDS bounds) V1 V2
Generic Function: check-beginning SELF OFFENDER
Package

serapeum/internal-definitions

Methods
Method: check-beginning (SELF internal-definitions-env) OFFENDER
Source

internal-definitions.lisp (file)

Generic Function: compare-elements KIND1 KIND2 TEST-KIND BOUNDS
Package

serapeum/vector=

Source

vector=.lisp (file)

Methods
Method: compare-elements (V1 vector) (V2 vector) TEST (BOUNDS bounds)
Method: compare-elements (V1 vector) (V2 vector) TEST (BOUNDS null)
Method: compare-elements (V1 vector) (V2 vector) (TEST test/equalp) (BOUNDS null)
Method: compare-elements (V1 simple-array-unsigned-byte-8) (V2 simple-array-unsigned-byte-8) (TEST test/rat=) (BOUNDS bounds)
Method: compare-elements (V1 simple-array-unsigned-byte-8) (V2 simple-array-unsigned-byte-8) (TEST test/rat=) (BOUNDS null)
Method: compare-elements (V vector) (W vector-wrapper) TEST BOUNDS
Method: compare-elements (W vector-wrapper) (V vector) TEST BOUNDS
Method: compare-elements (W1 vector-wrapper) (W2 vector-wrapper) TEST BOUNDS
Method: compare-elements (W1 rat-vector) (W2 rat-vector) (TEST test/rat=) (BOUNDS null)
Method: compare-elements (W1 numeric-vector) (W2 numeric-vector) (TEST test/=) (BOUNDS null)
Method: compare-elements (V1 bit-vector) (V2 bit-vector) (TEST test/rat=) (BOUNDS bounds)
Method: compare-elements (V1 bit-vector) (V2 bit-vector) (TEST test/rat=) (BOUNDS null)
Method: compare-elements (S1 string) (S2 string) (TEST test/char-equal) (BOUNDS bounds)
Method: compare-elements (S1 string) (S2 string) (TEST test/char=) (BOUNDS bounds)
Method: compare-elements (S1 string) (S2 string) (TEST test/char-equal) (BOUNDS null)
Method: compare-elements (S1 string) (S2 string) (TEST test/char=) (BOUNDS null)
Generic Function: constructor-values/generic X
Package

serapeum

Source

defining-types.lisp (file)

Methods
Method: constructor-values/generic (X bounds)
Source

vector=.lisp (file)

Generic Function: eject-macro SELF NAME WRAPPER
Package

serapeum/internal-definitions

Methods
Method: eject-macro (SELF internal-definitions-env) NAME WRAPPER
Source

internal-definitions.lisp (file)

Generic Function: ensure-var-alias SELF VAR
Package

serapeum/internal-definitions

Methods
Method: ensure-var-alias (SELF internal-definitions-env) VAR
Source

internal-definitions.lisp (file)

Generic Function: expand-body SELF BODY
Package

serapeum/internal-definitions

Methods
Method: expand-body (SELF internal-definitions-env) BODY

Shorthand for recursing on an implicit ‘progn’.

Source

internal-definitions.lisp (file)

Generic Function: expand-in-env SELF FORM &optional ENV
Package

serapeum/internal-definitions

Methods
Method: expand-in-env (SELF internal-definitions-env) FORM &optional ENV
Source

internal-definitions.lisp (file)

Generic Function: expand-in-env-1 SELF FORM &optional ENV
Package

serapeum/internal-definitions

Methods
Method: expand-in-env-1 (SELF internal-definitions-env) FORM &optional ENV

Like macroexpand-1, but handle local symbol macro bindings.

Source

internal-definitions.lisp (file)

Generic Function: expand-partially SELF FORM
Package

serapeum/internal-definitions

Methods
Method: expand-partially (SELF internal-definitions-env) FORM

Macro-expand FORM until it becomes a definition form or macro expansion stops.

Source

internal-definitions.lisp (file)

Generic Function: expand-top SELF FORMS
Package

serapeum/internal-definitions

Methods
Method: expand-top (SELF internal-definitions-env) FORMS
Source

internal-definitions.lisp (file)

Generic Function: expansion-done SELF FORM
Package

serapeum/internal-definitions

Methods
Method: expansion-done (SELF internal-definitions-env) FORM
Source

internal-definitions.lisp (file)

Generic Function: generate-internal-definitions SELF BODY
Package

serapeum/internal-definitions

Methods
Method: generate-internal-definitions (SELF internal-definitions-env) BODY
Source

internal-definitions.lisp (file)

Generic Function: hoisted-var? SELF VAR
Package

serapeum/internal-definitions

Methods
Method: hoisted-var? (SELF internal-definitions-env) VAR
Source

internal-definitions.lisp (file)

Generic Function: in-subenv? SELF
Package

serapeum/internal-definitions

Methods
Method: in-subenv? (SELF internal-definitions-env)

Are we within a binding form?

Source

internal-definitions.lisp (file)

Generic Function: known-var? SELF VAR
Package

serapeum/internal-definitions

Methods
Method: known-var? (SELF internal-definitions-env) VAR
Source

internal-definitions.lisp (file)

Generic Function: op-env-lambda OP-ENV
Package

serapeum/op

Methods
Method: op-env-lambda (OP-ENV op-env)
Source

op.lisp (file)

Generic Function: read-only-struct-slot-names X
Package

serapeum

Source

defining-types.lisp (file)

Method Combination

append (short method combination)

Options: :most-specific-first

Methods
Method: read-only-struct-slot-names (SELF unbound) append
Source

internal-definitions.lisp (file)

Method: read-only-struct-slot-names (SELF bounds) append
Source

vector=.lisp (file)

Method: read-only-struct-slot-names X append
Generic Function: save-symbol-macro SELF NAME EXP
Package

serapeum/internal-definitions

Methods
Method: save-symbol-macro (SELF internal-definitions-env) NAME EXP
Source

internal-definitions.lisp (file)

Generic Function: shadow-symbol-macro SELF NAME
Package

serapeum/internal-definitions

Methods
Method: shadow-symbol-macro (SELF internal-definitions-env) NAME
Source

internal-definitions.lisp (file)

Generic Function: splice-forms SELF SPLICED-FORMS
Package

serapeum/internal-definitions

Methods
Method: splice-forms (SELF internal-definitions-env) SPLICED-FORMS
Source

internal-definitions.lisp (file)

Generic Function: step-expansion SELF FORM
Package

serapeum/internal-definitions

Methods
Method: step-expansion (SELF internal-definitions-env) FORM
Source

internal-definitions.lisp (file)

Generic Function: test.fn TEST
Package

serapeum/vector=

Source

vector=.lisp (file)

Methods
Method: test.fn (TEST test/eq)
Method: test.fn (TEST test/eql)
Method: test.fn (TEST test/equal)
Method: test.fn (TEST test/char=)
Method: test.fn (TEST test/char-equal)
Method: test.fn (TEST test/=)
Method: test.fn (TEST test/equalp)
Method: test.fn (TEST function)
Generic Function: topmost-class OBJECT
Package

serapeum/mop

Methods
Method: topmost-class (TOPMOST-OBJECT-CLASS topmost-object-class)

automatically generated reader method

Source

mop.lisp (file)

Generic Function: unit-class-instance OBJECT
Package

serapeum

Methods
Method: unit-class-instance (UNIT-CLASS unit-class)

automatically generated reader method

Source

defining-types.lisp (file)

Generic Function: unwrap OBJECT
Package

serapeum/vector=

Methods
Method: unwrap (VECTOR-WRAPPER vector-wrapper)

automatically generated reader method

Source

vector=.lisp (file)

Generic Function: var-alias-bindings SELF
Package

serapeum/internal-definitions

Methods
Method: var-alias-bindings (SELF internal-definitions-env)
Source

internal-definitions.lisp (file)

Generic Function: wrap-bindings SELF BINDINGS
Package

serapeum/internal-definitions

Methods
Method: wrap-bindings (SELF internal-definitions-env) BINDINGS
Source

internal-definitions.lisp (file)

Generic Function: wrap-expr SELF FORM
Package

serapeum/internal-definitions

Methods
Method: wrap-expr (SELF internal-definitions-env) FORM
Source

internal-definitions.lisp (file)

Generic Function: wrap-fn-bindings SELF BINDINGS
Package

serapeum/internal-definitions

Methods
Method: wrap-fn-bindings (SELF internal-definitions-env) BINDINGS
Source

internal-definitions.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.8 Structures

Structure: %read-only-struct ()

Abstract base class for read-only structures.

Package

serapeum

Source

defining-types.lisp (file)

Direct superclasses

structure-object (structure)

Direct subclasses
Direct methods

make-load-form (method)

Structure: bounds ()
Package

serapeum/vector=

Source

vector=.lisp (file)

Direct superclasses

%read-only-struct (structure)

Direct methods
Direct slots
Slot: start1
Type

alexandria.0.dev:array-index

Initform

(alexandria.0.dev:required-argument (quote serapeum/vector=::start1))

Readers

bounds-start1 (function)

Writers

(setf bounds-start1) (function)

Slot: end1
Type

alexandria.0.dev:array-length

Initform

(alexandria.0.dev:required-argument (quote serapeum/vector=::end1))

Readers

bounds-end1 (function)

Writers

(setf bounds-end1) (function)

Slot: start2
Type

alexandria.0.dev:array-index

Initform

(alexandria.0.dev:required-argument (quote serapeum/vector=::start2))

Readers

bounds-start2 (function)

Writers

(setf bounds-start2) (function)

Slot: end2
Type

alexandria.0.dev:array-length

Initform

(alexandria.0.dev:required-argument (quote serapeum/vector=::end2))

Readers

bounds-end2 (function)

Writers

(setf bounds-end2) (function)

Structure: unbound ()

Placeholder for an unbound variable.

Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Direct superclasses

%read-only-struct (structure)

Direct methods
Direct slots
Slot: var
Type

symbol

Initform

(alexandria.0.dev:required-argument (quote serapeum/internal-definitions::var))

Readers

unbound-var (function)

Writers

(setf unbound-var) (function)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.9 Classes

Class: %binding ()
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Direct superclasses

standard-object (class)

Direct subclasses
Direct methods
Direct slots
Slot: name
Type

symbol

Initargs

:name

Readers

binding-name (generic function)

Slot: init
Type

serapeum/internal-definitions::expr

Initargs

:init

Readers

binding-init (generic function)

Class: float-vector ()
Package

serapeum/vector=

Source

vector=.lisp (file)

Direct superclasses

numeric-vector (class)

Class: fun ()
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Direct superclasses

%binding (class)

Class: internal-definitions-env ()
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Direct superclasses

standard-object (class)

Direct methods
Direct slots
Slot: vars
Type

list

Slot: var-aliases
Type

list

Slot: decls
Type

list

Initargs

:decls

Slot: hoisted-vars
Type

list

Slot: labels
Type

list

Slot: exprs
Type

list

Slot: global-symbol-macros
Type

list

Slot: env

The Lisp environment.

Initargs

:env

Direct Default Initargs
InitargValue
:envnil
:declsnil
Class: macro ()
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Direct superclasses

%binding (class)

Class: numeric-vector ()
Package

serapeum/vector=

Source

vector=.lisp (file)

Direct superclasses

vector-wrapper (class)

Direct subclasses
Direct methods

compare-elements (method)

Class: op-env ()
Package

serapeum/op

Source

op.lisp (file)

Direct superclasses

standard-object (class)

Direct methods

op-env-lambda (method)

Direct slots
Slot: body
Type

list

Initargs

:body, :body

Slot: vars
Type

list

Initargs

:vars

Slot: rest-op?
Type

symbol

Initargs

:rest-op?

Class: rat-vector ()
Package

serapeum/vector=

Source

vector=.lisp (file)

Direct superclasses

numeric-vector (class)

Direct methods

compare-elements (method)

Class: subenv ()

Minimal lexical environment.

Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Direct superclasses

standard-object (class)

Direct methods
Direct slots
Slot: vars
Type

list

Initargs

:vars

Readers

.vars (generic function)

Slot: funs
Type

list

Initargs

:funs

Readers

.funs (generic function)

Slot: blocks
Type

list

Initargs

:blocks

Readers

.blocks (generic function)

Slot: tags
Type

list

Initargs

:tags

Readers

.tags (generic function)

Direct Default Initargs
InitargValue
:varsnil
:funsnil
:blocksnil
:tagsnil
Class: symbol-macro ()
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Direct superclasses

%binding (class)

Class: test/= ()
Package

serapeum/vector=

Source

vector=.lisp (file)

Direct superclasses

test/rat= (class)

Direct subclasses

test/equalp (class)

Direct methods
Class: test/char-equal ()
Package

serapeum/vector=

Source

vector=.lisp (file)

Direct superclasses

test/char= (class)

Direct subclasses

test/equalp (class)

Direct methods
Class: test/char= ()
Package

serapeum/vector=

Source

vector=.lisp (file)

Direct superclasses

standard-object (class)

Direct subclasses
Direct methods
Class: test/eq ()
Package

serapeum/vector=

Source

vector=.lisp (file)

Direct superclasses

standard-object (class)

Direct subclasses

test/eql (class)

Direct methods

test.fn (method)

Class: test/eql ()
Package

serapeum/vector=

Source

vector=.lisp (file)

Direct superclasses
Direct subclasses

test/equal (class)

Direct methods

test.fn (method)

Class: test/equal ()
Package

serapeum/vector=

Source

vector=.lisp (file)

Direct superclasses

test/eql (class)

Direct subclasses

test/equalp (class)

Direct methods

test.fn (method)

Class: test/equalp ()
Package

serapeum/vector=

Source

vector=.lisp (file)

Direct superclasses
Direct methods
Class: test/rat= ()
Package

serapeum/vector=

Source

vector=.lisp (file)

Direct superclasses

standard-object (class)

Direct subclasses
Direct methods
Class: unit-class ()
Package

serapeum

Source

defining-types.lisp (file)

Direct superclasses

topmost-object-class (class)

Direct methods
Direct slots
Slot: lock
Initform

(bordeaux-threads:make-lock)

Slot: instance
Readers

unit-class-instance (generic function)

Direct Default Initargs
InitargValue
:topmost-class(quote serapeum::unit-object)
Class: unit-object ()

Superclass for instances of unit classes.
Gives us a place to hang specializations for ‘print-object’ and ‘make-load-form’.

Package

serapeum

Source

defining-types.lisp (file)

Direct superclasses

standard-object (class)

Direct methods
  • make-load-form (method)
  • print-object (method)
Class: var ()
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Direct superclasses

%binding (class)

Class: vector-wrapper ()
Package

serapeum/vector=

Source

vector=.lisp (file)

Direct superclasses

standard-object (class)

Direct subclasses

numeric-vector (class)

Direct methods
Direct slots
Slot: vector
Type

vector

Initargs

:vector

Readers

unwrap (generic function)


Previous: , Up: Internal definitions   [Contents][Index]

6.2.10 Types

Type: binding ()
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Type: body ()
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Type: expr ()
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Type: function-name ()
Package

serapeum

Source

sequences.lisp (file)

Type: heap ()
Package

serapeum

Source

sequences.lisp (file)

Type: internal-definition-form ()
Package

serapeum/internal-definitions

Source

internal-definitions.lisp (file)

Type: key-designator ()
Package

serapeum

Source

sequences.lisp (file)

Type: real* ()
Package

serapeum

Source

range.lisp (file)

Type: signed-array-index ()

A (possibly negated) array index.

Package

serapeum

Source

sequences.lisp (file)

Type: signed-array-length ()

A (possibly negated) array length.

Package

serapeum

Source

sequences.lisp (file)

Type: string-offset ()
Package

serapeum

Source

strings.lisp (file)

Type: test-designator ()
Package

serapeum

Source

sequences.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L   M   S  
Index Entry  Section

F
File, Lisp, serapeum.asd: The serapeum<dot>asd file
File, Lisp, serapeum/level0/arrays.lisp: The serapeum/level0/arrays<dot>lisp file
File, Lisp, serapeum/level0/binding.lisp: The serapeum/level0/binding<dot>lisp file
File, Lisp, serapeum/level0/box.lisp: The serapeum/level0/box<dot>lisp file
File, Lisp, serapeum/level0/clos.lisp: The serapeum/level0/clos<dot>lisp file
File, Lisp, serapeum/level0/conditions.lisp: The serapeum/level0/conditions<dot>lisp file
File, Lisp, serapeum/level0/control-flow.lisp: The serapeum/level0/control-flow<dot>lisp file
File, Lisp, serapeum/level0/defining-types.lisp: The serapeum/level0/defining-types<dot>lisp file
File, Lisp, serapeum/level0/definitions.lisp: The serapeum/level0/definitions<dot>lisp file
File, Lisp, serapeum/level0/fbind.lisp: The serapeum/level0/fbind<dot>lisp file
File, Lisp, serapeum/level0/files.lisp: The serapeum/level0/files<dot>lisp file
File, Lisp, serapeum/level0/functions.lisp: The serapeum/level0/functions<dot>lisp file
File, Lisp, serapeum/level0/hash-tables.lisp: The serapeum/level0/hash-tables<dot>lisp file
File, Lisp, serapeum/level0/hooks.lisp: The serapeum/level0/hooks<dot>lisp file
File, Lisp, serapeum/level0/iter.lisp: The serapeum/level0/iter<dot>lisp file
File, Lisp, serapeum/level0/macro-tools.lisp: The serapeum/level0/macro-tools<dot>lisp file
File, Lisp, serapeum/level0/numbers.lisp: The serapeum/level0/numbers<dot>lisp file
File, Lisp, serapeum/level0/octets.lisp: The serapeum/level0/octets<dot>lisp file
File, Lisp, serapeum/level0/op.lisp: The serapeum/level0/op<dot>lisp file
File, Lisp, serapeum/level0/queue.lisp: The serapeum/level0/queue<dot>lisp file
File, Lisp, serapeum/level0/symbols.lisp: The serapeum/level0/symbols<dot>lisp file
File, Lisp, serapeum/level0/threads.lisp: The serapeum/level0/threads<dot>lisp file
File, Lisp, serapeum/level0/time.lisp: The serapeum/level0/time<dot>lisp file
File, Lisp, serapeum/level0/trees.lisp: The serapeum/level0/trees<dot>lisp file
File, Lisp, serapeum/level0/types.lisp: The serapeum/level0/types<dot>lisp file
File, Lisp, serapeum/level1/lists.lisp: The serapeum/level1/lists<dot>lisp file
File, Lisp, serapeum/level1/sequences.lisp: The serapeum/level1/sequences<dot>lisp file
File, Lisp, serapeum/level1/strings.lisp: The serapeum/level1/strings<dot>lisp file
File, Lisp, serapeum/level1/vectors.lisp: The serapeum/level1/vectors<dot>lisp file
File, Lisp, serapeum/level2/dispatch-case.lisp: The serapeum/level2/dispatch-case<dot>lisp file
File, Lisp, serapeum/level2/internal-definitions.lisp: The serapeum/level2/internal-definitions<dot>lisp file
File, Lisp, serapeum/level2/mop.lisp: The serapeum/level2/mop<dot>lisp file
File, Lisp, serapeum/level2/range.lisp: The serapeum/level2/range<dot>lisp file
File, Lisp, serapeum/level2/tree-case.lisp: The serapeum/level2/tree-case<dot>lisp file
File, Lisp, serapeum/level2/vector=.lisp: The serapeum/level2/vector=<dot>lisp file
File, Lisp, serapeum/package.lisp: The serapeum/package<dot>lisp file

L
Lisp File, serapeum.asd: The serapeum<dot>asd file
Lisp File, serapeum/level0/arrays.lisp: The serapeum/level0/arrays<dot>lisp file
Lisp File, serapeum/level0/binding.lisp: The serapeum/level0/binding<dot>lisp file
Lisp File, serapeum/level0/box.lisp: The serapeum/level0/box<dot>lisp file
Lisp File, serapeum/level0/clos.lisp: The serapeum/level0/clos<dot>lisp file
Lisp File, serapeum/level0/conditions.lisp: The serapeum/level0/conditions<dot>lisp file
Lisp File, serapeum/level0/control-flow.lisp: The serapeum/level0/control-flow<dot>lisp file
Lisp File, serapeum/level0/defining-types.lisp: The serapeum/level0/defining-types<dot>lisp file
Lisp File, serapeum/level0/definitions.lisp: The serapeum/level0/definitions<dot>lisp file
Lisp File, serapeum/level0/fbind.lisp: The serapeum/level0/fbind<dot>lisp file
Lisp File, serapeum/level0/files.lisp: The serapeum/level0/files<dot>lisp file
Lisp File, serapeum/level0/functions.lisp: The serapeum/level0/functions<dot>lisp file
Lisp File, serapeum/level0/hash-tables.lisp: The serapeum/level0/hash-tables<dot>lisp file
Lisp File, serapeum/level0/hooks.lisp: The serapeum/level0/hooks<dot>lisp file
Lisp File, serapeum/level0/iter.lisp: The serapeum/level0/iter<dot>lisp file
Lisp File, serapeum/level0/macro-tools.lisp: The serapeum/level0/macro-tools<dot>lisp file
Lisp File, serapeum/level0/numbers.lisp: The serapeum/level0/numbers<dot>lisp file
Lisp File, serapeum/level0/octets.lisp: The serapeum/level0/octets<dot>lisp file
Lisp File, serapeum/level0/op.lisp: The serapeum/level0/op<dot>lisp file
Lisp File, serapeum/level0/queue.lisp: The serapeum/level0/queue<dot>lisp file
Lisp File, serapeum/level0/symbols.lisp: The serapeum/level0/symbols<dot>lisp file