The clith Reference Manual

This is the clith Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 05:40:34 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

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


2.1 clith

Common Lisp wITH macro. A general WITH macro.

Author

Héctor Galbis Sanchis

License

MIT

Dependency

alexandria (system).

Source

clith.asd.

Child Component

src (module).


3 Modules

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


3.1 clith/src

Source

clith.asd.

Parent Component

clith (system).

Child Components

4 Files

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


4.1 Lisp


4.1.1 clith/clith.asd

Source

clith.asd.

Parent Component

clith (system).

ASDF Systems

clith.


4.1.2 clith/src/package.lisp

Source

clith.asd.

Parent Component

src (module).

Packages

clith.


4.1.3 clith/src/clith.lisp

Dependency

package.lisp (file).

Source

clith.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.4 clith/src/definitions.lisp

Dependency

clith.lisp (file).

Source

clith.asd.

Parent Component

src (module).


5 Packages

Packages are listed by definition order.


5.1 clith

Source

package.lisp.

Use List
  • alexandria.
  • common-lisp.
Public Interface
Internals

6 Definitions

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


6.1 Public Interface


6.1.1 Macros

Macro: defwith (name (vars args &rest with-body) &body body)

Define a WITH macro. A WITH macro controls how a WITH binding form is expanded. This macro has
the following syntax:

(DEFWITH name (vars args with-body*) declaration* body*)

name ::= symbol
vars ::= (var-with-options*)
var-with-options ::= symbol | (symbol option*)
option ::= form
args ::= destructuring-lambda-list
with-body ::= form
declaration ::= declaration-form | docstring
body ::= form

The symbol NAME will be available to use inside WITH performing a custom expansion defined by DEFWITH. The variables to be bound are passed through VARS (VARS will always be a list) and the arguments passed to NAME are bound to ARGS. Finally, WITH-BODY is bound to the body of the WITH macro. Note that WITH-BODY can contain declarations.

As an example, let’s define the with expander MY-FILE. We will make WITH to be expanded to WITH-OPEN-FILE.

(defwith my-file (vars (filespec &rest options) &body body)
"Open a file."
(with-gensyms (stream)
‘(with-open-file (,stream ,filespec ,@options)
(multiple-value-bind ,vars ,stream
,@body))))

As VARS is always a list, we can use MULTIPLE-VALUE-BIND in case additional variables are passed. Also, we are assuming here that no additional options are passed with the variables to be bound.

Now, using WITH:

(with ((file (my-file "~/file.txt" :direction :output)))
(print "Hey!" file))

Finally, note that we put a docstring in MY-FILE. We can retrieve it with DOCUMENTATION:

(documentation ’my-file ’with) ;; –> "Open a file."

Package

clith.

Source

clith.lisp.

Macro: with (bindings &body body)

This macro has the following systax:

(WITH (binding*) declaration* form*)

binding ::= ([vars] form)
vars ::= var | (var-with-options*)
var-with-options ::= var | (var var-option*)
var-option ::= form

WITH accepts a list of binding clauses. Each binding clause must be a list. The variables are optional, so we can as clauses lists with one or two elements:

- A list with one element: That element is a form that must be a WITH expander defined with DEFWITH.
In this case, the WITH expander will receive NIL as the list of variables to be bound.

(with (((my-function arg))) ; <- expanded using the expansion of my-function
...)

- A list with two elements: The first element must be a symbol or a list of symbols with or without options.
The second element is a form that must be a WITH expander.

(with (((member1 (myvar member2)) (slots object)) ; <- MEMBER1 and MYVAR are bound with the values from
the class members MEMBER1 and MEMBER2 of OBJECT
...)

Here, MEMBER2 is an option of MYVAR. Options can be of any form, not just symbols. As SLOTS is a
with expander defined with DEFWITH, it will receive (MEMBER1 (MYVAR MEMBER2)) as the variables to be bound,
but only MEMBER1 and MYVAR must/should be bound.

In order to define a WITH expander you must use DEFWITH.

Package

clith.

Source

clith.lisp.


6.2 Internals


6.2.1 Special variables

Special Variable: *cl-expanders*
Package

clith.

Source

clith.lisp.

Special Variable: *with-expanders*
Package

clith.

Source

clith.lisp.


6.2.2 Macros

Macro: define-cl-expander (name (vars with-body &rest args) &body body)

Define a cl macro. A cl macro controls how a WITH binding form is expanded when a cl name is encountered. This is a private macro and the user should not use it.

Package

clith.

Source

clith.lisp.


6.2.3 Ordinary functions

Function: canonize-binding (binding)
Package

clith.

Source

clith.lisp.

Function: check-binding (binding)
Package

clith.

Source

clith.lisp.

Function: check-bindings (bindings)
Package

clith.

Source

clith.lisp.

Function: check-form (form)
Package

clith.

Source

clith.lisp.

Function: check-variables (vars)
Package

clith.

Source

clith.lisp.

Function: cl-macro-binding-p (canonized-binding)
Package

clith.

Source

clith.lisp.

Function: extract-declaration-single-var (var declarations)
Package

clith.

Source

clith.lisp.

Function: extract-declarations (body)
Package

clith.

Source

clith.lisp.

Function: extract-docstring (body)

Returns the docstring and the body without that docstring.

Package

clith.

Source

clith.lisp.

Function: extract-var-declarations (vars declarations)
Package

clith.

Source

clith.lisp.

Function: make-cl-macro-form (binding body declaration)
Package

clith.

Source

clith.lisp.

Function: make-with-form (bindings body binding-declarations body-declarations)
Package

clith.

Source

clith.lisp.

Function: make-with-macro-form (binding body declaration)
Package

clith.

Source

clith.lisp.

Function: split-declarations (canonized-bindings declarations)
Package

clith.

Source

clith.lisp.

Function: var-declaration-p (id)
Package

clith.

Source

clith.lisp.

Function: with-macro-binding-p (canonized-binding)
Package

clith.

Source

clith.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   C   D   E   F   M   S   V   W  
Index Entry  Section

C
canonize-binding: Private ordinary functions
check-binding: Private ordinary functions
check-bindings: Private ordinary functions
check-form: Private ordinary functions
check-variables: Private ordinary functions
cl-macro-binding-p: Private ordinary functions

D
define-cl-expander: Private macros
defwith: Public macros

E
extract-declaration-single-var: Private ordinary functions
extract-declarations: Private ordinary functions
extract-docstring: Private ordinary functions
extract-var-declarations: Private ordinary functions

F
Function, canonize-binding: Private ordinary functions
Function, check-binding: Private ordinary functions
Function, check-bindings: Private ordinary functions
Function, check-form: Private ordinary functions
Function, check-variables: Private ordinary functions
Function, cl-macro-binding-p: Private ordinary functions
Function, extract-declaration-single-var: Private ordinary functions
Function, extract-declarations: Private ordinary functions
Function, extract-docstring: Private ordinary functions
Function, extract-var-declarations: Private ordinary functions
Function, make-cl-macro-form: Private ordinary functions
Function, make-with-form: Private ordinary functions
Function, make-with-macro-form: Private ordinary functions
Function, split-declarations: Private ordinary functions
Function, var-declaration-p: Private ordinary functions
Function, with-macro-binding-p: Private ordinary functions

M
Macro, define-cl-expander: Private macros
Macro, defwith: Public macros
Macro, with: Public macros
make-cl-macro-form: Private ordinary functions
make-with-form: Private ordinary functions
make-with-macro-form: Private ordinary functions

S
split-declarations: Private ordinary functions

V
var-declaration-p: Private ordinary functions

W
with: Public macros
with-macro-binding-p: Private ordinary functions