This is the chain Reference Manual, version 0.0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Tue Jul 15 03:31:25 2025 GMT+0.
The main system appears first, followed by any subsystem dependency.
chainTwo chaining/piping macros, one of them ‘setf‘ing its first argument
Thomas Bartscher <thomas-bartscher@weltraumschlangen.de>
BSD-3
0.0.1
metabang-bind (system).
mgl-pax (system).
package.lisp (file).
chain.lisp (file).
Files are sorted by type and then listed depth-first from the systems components trees.
chain/package.lispchain/chain.lisppackage.lisp (file).
chain (system).
chop (macro).
expand-chain (function).
Packages are listed by definition order.
chaincommon-lisp.
metabang.bind.
mgl-pax.
@chain (special variable).
chop (macro).
expand-chain (function).
Definitions are sorted by export status, category, package, and then by lexicographic order.
Thread a value through a series of transformations, where ‘%‘ represents the
value of the last transformation.
- Arguments
+ ‘argument‘: Initial value or a ‘(:var SYMBOL INITIAL-VALUE)‘ binding form.
+ ‘body‘: Forms to apply sequentially. Each form has ‘%‘ bound as an anaphoric
variable bound to the return value of the previous form in the body.
Each form may be:
* - A regular form
* - A ‘(:var SYMBOL EXPR)‘ form to bind ‘SYMBOL‘ to the result of evaluating
‘EXPR‘
* - A ‘(lambda (X) …)‘ form that is called on the result of the previous form.
- Return value
Returns the value of its last form.
- Examples
“‘lisp
;; Basic numeric pipeline
(=> 5
(* % 2) ; => 10
(1+ %))
=> 11
;; lambda form usage
(=> 5
(lambda (x) ; => 8
(+ x 3))
(* % 2))
=> 16
;; :var binding
(=> 5
(:var y (* % 3)) ; y = 15, % = 15
(1+ %) ; % = 16
(+ y %)) ; y + % = 15 + 16
=> 31
;; :var in argument position
(=> (:var a 5) ; a = 5, % = 5
(1+ %) ; % = 6
(+ a %)) ; a + % = 5 + 6
=> 11
“‘
Thread the initial value of a place through transformations like in macro
‘=>‘, and update the place with the final result.
- Arguments
+ ‘argument‘: A ‘setf‘-able place or ‘(:var SYMBOL PLACE)‘ where SYMBOL is a
variable name and PLACE is a ‘setf‘-able place. When refering to PLACE from
here on out, the ‘setf‘-able place is meant.
+ ‘body‘: Exactly the same as in macro ‘=>‘. Supports ‘:var‘, ‘lambda‘ and ‘%‘
the same as ‘=>‘.
- Return value
Returns the value of its last form.
- Side effects
Updates PLACE to the calculated result.
- Examples
“‘lisp
;;; Modify a variable
(let ((x 5))
(set=> x
(* % 2) ; => 10
(1+ %)) ; => 11
x)
=> 11
;; Using :var
(defstruct box (value 0))
(let ((b (make-box :value 8)))
(set=> (:var v (box-value b))
(+ % 5) ; => 13
(* v %)) ; => 8 * 13 = 104
(box-value b))
=> 104
“‘
| Jump to: | =
C E F M S |
|---|
| Index Entry | Section | ||
|---|---|---|---|
| | |||
| = | |||
=>: | Public macros | ||
| | |||
| C | |||
chop: | Private macros | ||
| | |||
| E | |||
expand-chain: | Private ordinary functions | ||
| | |||
| F | |||
Function, expand-chain: | Private ordinary functions | ||
| | |||
| M | |||
Macro, =>: | Public macros | ||
Macro, chop: | Private macros | ||
Macro, set=>: | Public macros | ||
| | |||
| S | |||
set=>: | Public macros | ||
| | |||
| Jump to: | =
C E F M S |
|---|
| Jump to: | @
S |
|---|
| Index Entry | Section | ||
|---|---|---|---|
| | |||
| @ | |||
@chain: | Private special variables | ||
| | |||
| S | |||
Special Variable, @chain: | Private special variables | ||
| | |||
| Jump to: | @
S |
|---|
| Jump to: | C F P S |
|---|
| Jump to: | C F P S |
|---|