The for Reference Manual

This is the for Reference Manual, version 1.2.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Feb 26 16:26:42 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

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


2.1 for

An extensible iteration macro library.

Maintainer

Yukari Hafner <>

Author

Yukari Hafner <>

Home Page

https://Shinmera.github.io/for/

Source Control

(GIT https://github.com/Shinmera/for.git)

Bug Tracker

https://github.com/Shinmera/for/issues

License

zlib

Version

1.2.0

Dependencies
  • documentation-utils (system).
  • lambda-fiddle (system).
  • form-fiddle (system).
Source

for.asd.

Child Components

3 Files

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


3.1 Lisp


3.1.1 for/for.asd

Source

for.asd.

Parent Component

for (system).

ASDF Systems

for.


3.1.2 for/package.lisp

Source

for.asd.

Parent Component

for (system).

Packages

3.1.3 for/toolkit.lisp

Dependency

package.lisp (file).

Source

for.asd.

Parent Component

for (system).

Public Interface
Internals

3.1.4 for/binding.lisp

Dependency

toolkit.lisp (file).

Source

for.asd.

Parent Component

for (system).

Public Interface
Internals

3.1.5 for/clause.lisp

Dependency

binding.lisp (file).

Source

for.asd.

Parent Component

for (system).

Public Interface
Internals

3.1.6 for/for.lisp

Dependency

clause.lisp (file).

Source

for.asd.

Parent Component

for (system).

Public Interface

for (macro).

Internals

3.1.7 for/iterator.lisp

Dependency

for.lisp (file).

Source

for.asd.

Parent Component

for (system).

Public Interface

3.1.8 for/standard.lisp

Dependency

iterator.lisp (file).

Source

for.asd.

Parent Component

for (system).

Internals

3.1.9 for/documentation.lisp

Dependency

standard.lisp (file).

Source

for.asd.

Parent Component

for (system).


4 Packages

Packages are listed by definition order.


4.1 for-minimal

Source

package.lisp.

Nickname

org.shirakumo.for.minimal

Use List

common-lisp.

Used By List

for.

Public Interface

4.2 for-iterator

Source

package.lisp.

Nickname

org.shirakumo.for.iterator

Use List

common-lisp.

Used By List

for.

Public Interface

4.3 for

Source

package.lisp.

Nickname

org.shirakumo.for

Use List
Public Interface
Internals

5 Definitions

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


5.1 Public Interface


5.1.1 Macros

Macro: define-accumulation-binding (name (var &rest args) &body body)

Defines a binding for an accumulator.

This is identical to DEFINE-FORM-BINDING with the exception that the secondary value is set to a (RETURN-FOR var) for you, meaning the variable’s contents are returned from the FOR upon normal termination.

See DEFINE-FORM-BINDING

Package

for.

Source

binding.lisp.

Macro: define-alias-binding (name referenced-binding-name)

Defines an alias for a binding.

See BINDING

Package

for.

Source

binding.lisp.

Macro: define-direct-binding (name args &body body)

Defines a binding function.

Binding functions can return three values:

1. A single "surrounding form" that will go around the resulting loop. If you require multiple surrounding forms, you can use WITH-INTERLEAVING.
2. A form to run during each iteration. They will be run before any body forms. 3. A form whose value is returned by the FOR.
4. A form to run during each iteration. They will be run *after* any body forms.

The arguments that the function receives are directly translated from the respective binding expression. One argument will always be passed in the very least: the variable specified for the binding.

Note that a binding function receives its arguments as literals and thus must process them like a macro would (destructive operations are bad juju).

Also note that unlike normal functions, the &environment lambda-list argument is available and its value will be passed on from the calling FOR macro.

See BINDING
See REMOVE-BINDING

Package

for.

Source

binding.lisp.

Macro: define-form-binding (name (var &rest args) &body body)

Defines a binding that receives its arguments as literals.

&AUX variables in the ARGS lambda-list receive special treatment: they are bound to gensyms within the definition body. Their value is only evaluated and set within the expanded binding. This means that &AUX variables give you a convenient way to introduce necessary helper variables to the expanded binding. References to other AUX variables or the VAR are automatically rewritten to the appropriate gensym.

VAR can also accept a default value, which receives the same semantic treatment as &AUX variables do, with the exception that it is always the last binding to be evaluated in the resulting expansion, meaning every other &AUX variable can be referenced.

The primary value returned must be the form to be evaluated on each iteration. A secondary value may be returned, which is a form to be evaluated when the loop ends normally.

See DEFINE-DIRECT-BINDING
See DEFINE-VALUE-BINDING

Package

for.

Source

binding.lisp.

Macro: define-form-symbol-macro-binding (name (var &rest args) &body body)

Defines a binding that receives its arguments as literals and treats the VAR as a symbol-macro.

This is the exact same as DEFINE-FORM-BINDING with the exception that the
VAR is translated into a symbol-macro binding. Its value is still translated
accordingly to make sure references to AUX variables stay intact.

See DEFINE-FORM-BINDING

Package

for.

Source

binding.lisp.

Macro: define-value-binding (name (var &rest args) &body body)

Defines a binding that receives its arguments as values.

The treatment of all arguments in the ARGS lambda-list is as follows: Within the definition body, they are bound to gensyms. Upon expansion of the binding, each variable is expanded to a variable binding with the respective value that was passed to the binding definition. Special exception is made for the present-p optional variables that can be specified for optional or key arguments, which are bound as usual in the definition body such that expansion may be aware of which parameters were passed. In essence, you can interpret all arguments as if treated by ONCE-ONLY.

&AUX variables in the args lambda-list receive special treatment: they are bound to gensyms within the definition body. Their value is only evaluated and set within the expanded binding. This means that AUX variables give you a convenient way to introduce necessary helper variables to the expanded binding. References to other arguments or the VAR are automatically rewritten to
the appropriate gensym.

VAR can also accept a default value, which receives the same semantic treatment as &AUX variables do, with the exception that it is always the last binding to be evaluated in the resulting expansion, meaning every other argument can be referenced.

The primary value returned must be the form to be evaluated on each iteration. A secondary value may be returned, which is a form to be evaluated when the loop ends normally.

See DEFINE-FORM-BINDING
See DEFINE-DIRECT-BINDING

Package

for.

Source

binding.lisp.

Macro: define-value-symbol-macro-binding (name (var &rest args) &body body)

Defines a binding that receives its arguments as values and treats the VAR as a symbol-macro.

This is the exact same as DEFINE-VALUE-BINDING with the exception that the
VAR is translated into a symbol-macro binding. Its value is still translated
accordingly to make sure references to arguments stay intact.

See DEFINE-VALUE-BINDING

Package

for.

Source

binding.lisp.

Macro: for (bindings &body body)

Loops the body with the given bindings established.

Each binding should have the form (var binding-type args*)

Sometimes a var can be either a single symbol denoting a variable, or a lambda-list to which the result is destructured and bound via UPDATE.
The support thereof depends on the binding construct.

Within the body, special iteration clauses may be present. A clause must appear at the "top-level" of the body and cannot appear as a macro-expansion.

If the loop is terminated normally by END-FOR then multiple values may be returned depending on how many bindings or clauses are present that want to return values. The order of the values is as follows: the clause values are returned in the order that the clauses appear in the body, followed by the binding values in the order of the binding expressions.

The loop may also be terminated abnormally by a direct call to RETURN-FOR or RETURN.

See UPDATE
See BINDING
See CLAUSE
See END-FOR
See SKIP-FOR
See RETURN-FOR
See WITH-FOR-TAGBODY
See WITH-FOR-BLOCK
See CONVERT-BINDINGS
See CONVERT-CLAUSES

Package

for-minimal.

Source

for.lisp.

Macro: update (place value-form)

Allows updating the PLACE with a new value.

Unlike just (setf place value), PLACE can also be a lambda-list where each variable is then properly updated with the respective element from value list.

Package

for-minimal.

Source

toolkit.lisp.

Macro: with-interleaving (&body body)

Interleave the body forms.

Essentially this means that the last form is appended to the form before it and this is then appended to the form before that, and so on.

Package

for.

Source

toolkit.lisp.


5.1.2 Ordinary functions

Function: binding (name)

Accessor to the function that compiles the given binding.

If there is no binding named by the given symbol directly, another search is performed using the symbol with the same symbol-name from the FOR package.

See REMOVE-BINDING

Package

for.

Source

binding.lisp.

Function: (setf binding) (name)
Package

for.

Source

binding.lisp.

Function: clause (name)

Accessor to the function that compiles the given clause.

If there is no clause named by the given symbol directly, another search is performed using the symbol with the same symbol-name from the FOR package.

See REMOVE-CLAUSE

Package

for.

Source

clause.lisp.

Function: (setf clause) (name)
Package

for.

Source

clause.lisp.

Function: hash-table-iterator (table)

Returns a function to iterate over a hash-table.

See CL:WITH-HASH-TABLE-ITERATOR

Package

for-iterator.

Source

toolkit.lisp.

Function: package-iterator (package statuses)

Returns a function to iterate over a package’s symbols.

See CL:WITH-PACKAGE-ITERATOR

Package

for-iterator.

Source

toolkit.lisp.

Function: remove-binding (name)

Removes the given binding function.

See BINDING

Package

for.

Source

binding.lisp.

Function: remove-clause (name)

Removes the given clause function.

See CLAUSE

Package

for.

Source

clause.lisp.


5.1.3 Generic functions

Generic Reader: buffer (object)

Accessor to the stream-iterator’s buffer.

See STREAM-ITERATOR

Package

for-iterator.

Methods
Reader Method: buffer ((stream-line-iterator stream-line-iterator))

automatically generated reader method

Source

iterator.lisp.

Target Slot

buffer.

Reader Method: buffer ((stream-iterator stream-iterator))

automatically generated reader method

Source

iterator.lisp.

Target Slot

buffer.

Generic Writer: (setf buffer) (object)
Package

for-iterator.

Methods
Writer Method: (setf buffer) ((stream-line-iterator stream-line-iterator))

automatically generated writer method

Source

iterator.lisp.

Target Slot

buffer.

Writer Method: (setf buffer) ((stream-iterator stream-iterator))

automatically generated writer method

Source

iterator.lisp.

Target Slot

buffer.

Generic Reader: close-stream (object)

Accessor to whether the stream should be closed on END call or not.

See STREAM-ITERATOR
See STREAM-LINE-ITERATOR

Package

for-iterator.

Methods
Reader Method: close-stream ((stream-line-iterator stream-line-iterator))

automatically generated reader method

Source

iterator.lisp.

Target Slot

close-stream.

Reader Method: close-stream ((stream-iterator stream-iterator))

automatically generated reader method

Source

iterator.lisp.

Target Slot

close-stream.

Generic Writer: (setf close-stream) (object)
Package

for-iterator.

Methods
Writer Method: (setf close-stream) ((stream-line-iterator stream-line-iterator))

automatically generated writer method

Source

iterator.lisp.

Target Slot

close-stream.

Writer Method: (setf close-stream) ((stream-iterator stream-iterator))

automatically generated writer method

Source

iterator.lisp.

Target Slot

close-stream.

Generic Reader: current (iterator)

Accessor to the current item of the iterator.

The behaviour is undefined if CURRENT is used before NEXT has been called for a first time. Some (but not all) iterators may support setting the current element to a new value.

See NEXT

Package

for-iterator.

Source

iterator.lisp.

Methods
Reader Method: current ((iterator iterator))

automatically generated reader method

Target Slot

current.

Generic Function: (setf current) (iterator)
Package

for-iterator.

Source

iterator.lisp.

Methods
Method: (setf current) ((iterator hash-table-iterator))
Method: (setf current) ((iterator stream-iterator))
Method: (setf current) ((iterator stream-iterator))
Method: (setf current) ((iterator stream-iterator))
Method: (setf current) ((iterator sequence-iterator))
Method: (setf current) ((iterator array-iterator))
Method: (setf current) ((iterator vector-iterator))
Method: (setf current) ((iterator list-iterator))
Writer Method: (setf current) ((iterator iterator))

automatically generated writer method

Target Slot

current.

Generic Function: end (iterator)

Ends the iterator and performs potential cleanup.

You should always call this function with your iterator object once you are done to ensure proper termination.

Package

for-iterator.

Source

iterator.lisp.

Methods
Method: end ((iterator stream-line-iterator))
Method: end ((iterator stream-iterator))
Method: end ((iterator iterator))
Generic Function: has-more (iterator)

Returns a generalised boolean indicating whether the iterator has more items or not.

Package

for-iterator.

Source

iterator.lisp.

Methods
Method: has-more ((iterator hash-table-iterator))
Method: has-more ((iterator package-iterator))
Method: has-more ((iterator random-iterator))
Method: has-more ((iterator stream-line-iterator))
Method: has-more ((iterator stream-iterator))
Method: has-more ((iterator sequence-iterator))
Method: has-more ((iterator array-iterator))
Method: has-more ((iterator vector-iterator))
Method: has-more ((iterator list-iterator))
Generic Reader: index (object)

Accessor to the current index within the buffer.

See STREAM-ITERATOR

Package

for-iterator.

Methods
Reader Method: index ((stream-iterator stream-iterator))

automatically generated reader method

Source

iterator.lisp.

Target Slot

index.

Generic Writer: (setf index) (object)
Package

for-iterator.

Methods
Writer Method: (setf index) ((stream-iterator stream-iterator))

automatically generated writer method

Source

iterator.lisp.

Target Slot

index.

Generic Reader: iterator (object)
Package

for-iterator.

Methods
Reader Method: iterator ((hash-table-iterator hash-table-iterator))

automatically generated reader method

Source

iterator.lisp.

Target Slot

iterator.

Reader Method: iterator ((sequence-iterator sequence-iterator))

automatically generated reader method

Source

iterator.lisp.

Target Slot

iterator.

Generic Writer: (setf iterator) (object)
Package

for-iterator.

Methods
Writer Method: (setf iterator) ((hash-table-iterator hash-table-iterator))

automatically generated writer method

Source

iterator.lisp.

Target Slot

iterator.

Writer Method: (setf iterator) ((sequence-iterator sequence-iterator))

automatically generated writer method

Source

iterator.lisp.

Target Slot

iterator.

Generic Reader: limit (object)

Accessor to the amount of data that is currently filled in the buffer.

See STREAM-ITERATOR

Package

for-iterator.

Methods
Reader Method: limit ((random-iterator random-iterator))

automatically generated reader method

Source

iterator.lisp.

Target Slot

limit.

Reader Method: limit ((stream-iterator stream-iterator))

automatically generated reader method

Source

iterator.lisp.

Target Slot

limit.

Generic Writer: (setf limit) (object)
Package

for-iterator.

Methods
Writer Method: (setf limit) ((stream-iterator stream-iterator))

automatically generated writer method

Source

iterator.lisp.

Target Slot

limit.

Generic Function: make-iterator (object &key limit buffer-size element-type close-stream start &allow-other-keys)

Create an iterator object for the given type of object.

Package

for-iterator.

Source

iterator.lisp.

Methods
Method: make-iterator ((hash-table hash-table) &key)
Method: make-iterator ((package package) &key)
Method: make-iterator ((random-state random-state) &key limit)
Method: make-iterator ((pathname pathname) &key buffer-size element-type)
Method: make-iterator ((stream stream) &key buffer-size close-stream)
Method: make-iterator ((sequence sequence) &key)
Method: make-iterator ((array array) &key start)
Method: make-iterator ((vector vector) &key start)
Method: make-iterator ((list list) &key)
Generic Function: next (iterator)

Advances the iterator by one item and returns the new item.

The behaviour is undefined if the iterator does not have more items.

See HAS-MORE

Package

for-iterator.

Source

iterator.lisp.

Methods
Method: next ((iterator hash-table-iterator))
Method: next ((iterator package-iterator))
Method: next ((iterator random-iterator))
Method: next ((iterator stream-line-iterator))
Method: next ((iterator stream-iterator))
Method: next ((iterator sequence-iterator))
Method: next ((iterator array-iterator))
Method: next ((iterator vector-iterator))
Method: next ((iterator list-iterator))
Method: next :around ((iterator iterator))
Generic Reader: object (object)

Accessor to the data structure the iterator is iterating over.

Note that this is not necessarily the same object as what was passed into the constructor of the iterator. The iterator is free to modify this slot as it sees fit.

See ITERATOR

Package

for-iterator.

Methods
Reader Method: object ((iterator iterator))

automatically generated reader method

Source

iterator.lisp.

Target Slot

object.

Generic Writer: (setf object) (object)
Package

for-iterator.

Methods
Writer Method: (setf object) ((iterator iterator))

automatically generated writer method

Source

iterator.lisp.

Target Slot

object.

Generic Reader: prefetch (object)

Cache for the next value

Since the iterator constructs provided by CL do not allow merely testing whether a next element is available without losing it if there is one, we must cache the value on a HAS-MORE call and then use that on NEXT instead of calling the iterator function twice.

See PACKAGE-ITERATOR
See HASH-TABLE-ITERATOR

Package

for-iterator.

Methods
Reader Method: prefetch ((hash-table-iterator hash-table-iterator))

automatically generated reader method

Source

iterator.lisp.

Target Slot

prefetch.

Reader Method: prefetch ((package-iterator package-iterator))

automatically generated reader method

Source

iterator.lisp.

Target Slot

prefetch.

Generic Writer: (setf prefetch) (object)
Package

for-iterator.

Methods
Writer Method: (setf prefetch) ((hash-table-iterator hash-table-iterator))

automatically generated writer method

Source

iterator.lisp.

Target Slot

prefetch.

Writer Method: (setf prefetch) ((package-iterator package-iterator))

automatically generated writer method

Source

iterator.lisp.

Target Slot

prefetch.

Generic Reader: start (object)

Accessor to the index that points to the next element of the vector-iterator.

Package

for-iterator.

Methods
Reader Method: start ((vector-iterator vector-iterator))

automatically generated reader method

Source

iterator.lisp.

Target Slot

start.

Generic Writer: (setf start) (object)
Package

for-iterator.

Methods
Writer Method: (setf start) ((vector-iterator vector-iterator))

automatically generated writer method

Source

iterator.lisp.

Target Slot

start.

Generic Function: step-functions (iterator)

Returns a set of functions to perform the iteration.

Returns four values:

NEXT — Function of zero arguments that returns the next element. HAS-MORE — Function of zero arguments that returns whether there are more elements available.
UPDATE — Function of one argument that sets the current element to the given value if possible.
END — Function of zero arguments to finalise the iteration.

Iterators may specialise on this method to return tailored stepping functions that avoid the CLOS dispatch cost. Note that calling these functions may or may not change the internal iterator state.

Package

for-iterator.

Source

iterator.lisp.

Methods
Method: step-functions ((iterator hash-table-iterator))
Method: step-functions ((iterator package-iterator))
Method: step-functions ((iterator random-iterator))
Method: step-functions ((iterator stream-line-iterator))
Method: step-functions ((iterator stream-iterator))
Method: step-functions ((iterator sequence-iterator))
Method: step-functions ((iterator array-iterator))
Method: step-functions ((iterator vector-iterator))
Method: step-functions ((iterator list-iterator))
Method: step-functions ((iterator iterator))
Generic Reader: total-length (object)

Slot holding the array-total-size.

See ARRAY-ITERATOR

Package

for-iterator.

Methods
Reader Method: total-length ((array-iterator array-iterator))

automatically generated reader method

Source

iterator.lisp.

Target Slot

total-length.

Generic Writer: (setf total-length) (object)
Package

for-iterator.

Methods
Writer Method: (setf total-length) ((array-iterator array-iterator))

automatically generated writer method

Source

iterator.lisp.

Target Slot

total-length.


5.1.4 Standalone methods

Method: initialize-instance :after ((iterator stream-iterator) &key buffer-size object)
Source

iterator.lisp.

Method: initialize-instance :after ((iterator package-iterator) &key object status)
Source

iterator.lisp.

Method: initialize-instance :after ((iterator directory-iterator) &key object)
Source

iterator.lisp.

Method: initialize-instance :after ((iterator array-iterator) &key object)
Source

iterator.lisp.

Method: initialize-instance :after ((iterator sequence-iterator) &key object start end)
Source

iterator.lisp.

Method: initialize-instance :after ((iterator list-iterator) &key object)
Source

iterator.lisp.

Method: initialize-instance :after ((iterator hash-table-iterator) &key object)
Source

iterator.lisp.


5.1.5 Classes

Class: array-iterator

Iterator for general arrays.

Iteration is in row-major order.

Supports setting the current element.

See VECTOR-ITERATOR
See TOTAL-LENGTH

Package

for-iterator.

Source

iterator.lisp.

Direct superclasses

vector-iterator.

Direct methods
Direct slots
Slot: total-length
Readers

total-length.

Writers

(setf total-length).

Class: directory-iterator

Iterator for a DIRECTORY listing.

On construction, this performs a simple DIRECTORY call on the given object and then iterates over the result list of pathnames. Thus, the pathname must be wild.

See LIST-ITERATOR

Package

for-iterator.

Source

iterator.lisp.

Direct superclasses

list-iterator.

Direct methods

initialize-instance.

Class: hash-table-iterator

Iterator for the key/value pairs in a package.

Each value returned by this iterator’s CURRENT/NEXT is always a list of two values, the respective key and its value.

Supports setting the current element.

See PREFETCH
See ITERATOR

Package

for-iterator.

Source

iterator.lisp.

Direct superclasses

iterator.

Direct methods
Direct slots
Slot: iterator
Readers

iterator.

Writers

(setf iterator).

Slot: prefetch
Readers

prefetch.

Writers

(setf prefetch).

Class: iterator

An iterator is responsible for iterating over a given data structure.

See HAS-MORE
See NEXT
See CURRENT
See MAKE-ITERATOR
See OBJECT

Package

for-iterator.

Source

iterator.lisp.

Direct subclasses
Direct methods
Direct slots
Slot: object
Initargs

:object

Readers

object.

Writers

(setf object).

Slot: current
Readers

current.

Writers

(setf current).

Class: list-iterator

Iterator for proper lists.

Supports setting the current element.

See ITERATOR

Package

for-iterator.

Source

iterator.lisp.

Direct superclasses

iterator.

Direct subclasses

directory-iterator.

Direct methods
Class: package-iterator

Iterator for the symbols in a package.

The type of symbols that are iterated can be set through the :STATUS initarg, which must be a list containing any of the following keywords: :INTERNAL :EXTERNAL :INHERITED

See PREFETCH
See ITERATOR

Package

for-iterator.

Source

iterator.lisp.

Direct superclasses

iterator.

Direct methods
Direct Default Initargs
InitargValue
:status(quote (internal external inherited))
Direct slots
Slot: prefetch
Readers

prefetch.

Writers

(setf prefetch).

Class: random-iterator

Iterator for random numbers.

This iterator can be constructed through a RANDOM-STATE object. The argument for RANDOM that determines its limit can be passed through the :LIMIT initarg.

See ITERATOR

Package

for-iterator.

Source

iterator.lisp.

Direct superclasses

iterator.

Direct methods
Direct Default Initargs
InitargValue
:limit1.0
Direct slots
Slot: limit
Initargs

:limit

Readers

limit.

Writers

This slot is read-only.

Class: sequence-iterator
Package

for-iterator.

Source

iterator.lisp.

Direct superclasses

iterator.

Direct methods
Direct slots
Slot: iterator
Readers

iterator.

Writers

(setf iterator).

Class: stream-iterator

Iterator for input streams.

The stream is read through a buffer, the size of which can be set via the :BUFFER-SIZE initarg. If :CLOSE-STREAM is set to non-NIL, CLOSE is performed on the stream upon END.

Supports setting the "current" element if the stream supports writing to it of course.

See BUFFER
See INDEX
See LIMIT
See ITERATOR

Package

for-iterator.

Source

iterator.lisp.

Direct superclasses

iterator.

Direct methods
Direct slots
Slot: buffer
Readers

buffer.

Writers

(setf buffer).

Slot: index
Initform

1

Readers

index.

Writers

(setf index).

Slot: limit
Initform

1

Readers

limit.

Writers

(setf limit).

Slot: close-stream
Initargs

:close-stream

Readers

close-stream.

Writers

(setf close-stream).

Class: stream-line-iterator

Iterator for line based input streams.

If :CLOSE-STREAM is set to non-NIL, CLOSE is performed on the stream upon END.

See BUFFER
See CLOSE-STREAM
See ITERATOR

Package

for-iterator.

Source

iterator.lisp.

Direct superclasses

iterator.

Direct methods
Direct slots
Slot: buffer
Readers

buffer.

Writers

(setf buffer).

Slot: close-stream
Initargs

:close-stream

Readers

close-stream.

Writers

(setf close-stream).

Class: vector-iterator

Iterator for vectors.

Supports setting the current element.

See START
See ITERATOR

Package

for-iterator.

Source

iterator.lisp.

Direct superclasses

iterator.

Direct subclasses

array-iterator.

Direct methods
Direct Default Initargs
InitargValue
:start0
Direct slots
Slot: start
Initargs

:start

Readers

start.

Writers

(setf start).


5.2 Internals


5.2.1 Special variables

Special Variable: *bindings*
Package

for.

Source

binding.lisp.

Special Variable: *clauses*
Package

for.

Source

clause.lisp.

Special Variable: *environment*

This variable will be bound to the environment object during the expansion of the FOR macro.

Package

for.

Source

for.lisp.

Special Variable: *unbound*
Package

for.

Source

standard.lisp.


5.2.2 Macros

Macro: define-direct-clause (name args &body body)

Defines a clause function.

Clause functions can return three values:

1. A single "surrounding form" that will go around the resulting loop. If you require multiple surrounding forms, you can use WITH-INTERLEAVING.
2. A form to run during each iteration.
3. A form whose value is returned by the FOR.

The arguments that the function receives are directly translated from the respective clause expression.

Note that a clause function receives its arguments as literals and thus must process them like a macro would (destructive operations are bad juju).

Also note that unlike normal functions, the &environment lambda-list argument is available and its value will be passed on from the calling FOR macro.

See CLAUSE
See REMOVE-CLAUSE

Package

for.

Source

clause.lisp.

Macro: define-simple-clause (name args &body body)

Defines a simple clause.

&AUX variables in the args lambda-list receive special treatment: they are bound to gensyms within the definition body. Their value is only evaluated and set within the expanded clause. This means that AUX variables give you a convenient way to introduce necessary helper variables to the expanded clause. References to other &AUX are automatically rewritten to the appropriate gensym.

The primary value returned must be the form to be evaluated on each iteration. A secondary value may be returned, which is a form to be evaluated when the loop ends normally.

See DEFINE-DIRECT-CLAUSE

Package

for.

Source

clause.lisp.

Macro: unwind-protect* (cleanup &body body)
Package

for.

Source

toolkit.lisp.

Macro: values* (&rest values)

The same idea as LIST* except for values.

Package

for.

Source

toolkit.lisp.

Macro: with-for-block (() &body body)

Wraps the body in a looping block.

This establishes a NIL block.

See RETURN-FOR

Package

for.

Source

for.lisp.

Macro: with-for-tagbody (body &body exit)

Wraps the body in a looping tagbody, running the EXIT forms when the loop ends.

See END-FOR
See SKIP-FOR

Package

for.

Source

for.lisp.


5.2.3 Ordinary functions

Function: bindings-for-gens (aux gens)
Package

for.

Source

binding.lisp.

Function: collect-for-values (expressions function)
Package

for.

Source

toolkit.lisp.

Function: compute-binding-parts (var vars args)
Package

for.

Source

binding.lisp.

Function: compute-declaration-parts (body inner-let)
Package

for.

Source

binding.lisp.

Function: convert-bindings (bindings)

Translates the given binding expressions into their respective parts.

Each binding must be a list of the following structure:

BINDING ::= (PLACE binding-type argument*)
PLACE ::= variable | lambda-list
variable — A symbol naming a variable to bind the result of the binding to. lambda-list — If the binding result is a list, destructure it by this lambda- list, binding the respective symbols.
binding-type — The type of binding determines how the PLACE is initialised and how it changes each iteration.
argument — An argument to the binding. Depending on the binding it may be evaluated once or in every iteration.

If an unknown binding is referenced, an error is signalled.

Returns three values:
1. A list of all surrounding forms
2. A list of all body forms
3. A list of all value forms

See BINDING

Package

for.

Source

binding.lisp.

Function: convert-clauses (forms)

Translates the given body forms into their respective parts.

If a body form is noticed that matches a clause –by virtue of being a list and the first item thereof being a symbol that translates to a clause name– then it is replaced by the form computed by the clause function.

Returns three values:
1. A list of all surrounding forms
2. A list of all body forms
3. A list of all value forms

See CLAUSE

Package

for.

Source

clause.lisp.

Function: copy-list* (list)

Same as COPY-LIST, but also returning the last cons of the new list as a second value.

Package

for.

Source

toolkit.lisp.

Function: delist (a &optional key)

If A is a list, return the element that KEY retrieves.

Package

for.

Source

toolkit.lisp.

Function: emit-binding-definition (name var args body &key extra-vars symbol-macro-p)
Package

for.

Source

binding.lisp.

Function: enlist (a &rest els)

If A is not a list, turn it into one with the given ELS as further items.

Package

for.

Source

toolkit.lisp.

Function: normalize-declaration-inner (inner)
Package

for.

Source

binding.lisp.

Function: normalize-declarations (body)
Package

for.

Source

binding.lisp.

Function: remove-bindings (bindings form)
Package

for.

Source

standard.lisp.

Function: replace-lambda-vars (lambda-list vars new-vars)

Replaces all VARS in LAMBDA-LIST with the NEW-VAR at the same position.

Package

for.

Source

toolkit.lisp.

Function: translate-form-vars (form from to)
Package

for.

Source

binding.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   (  
B   C   D   E   F   G   H   I   L   M   N   O   P   R   S   T   U   V   W  
Index Entry  Section

(
(setf binding): Public ordinary functions
(setf buffer): Public generic functions
(setf buffer): Public generic functions
(setf buffer): Public generic functions
(setf clause): Public ordinary functions
(setf close-stream): Public generic functions
(setf close-stream): Public generic functions
(setf close-stream): Public generic functions
(setf current): Public generic functions
(setf current): Public generic functions
(setf current): Public generic functions
(setf current): Public generic functions
(setf current): Public generic functions
(setf current): Public generic functions
(setf current): Public generic functions
(setf current): Public generic functions
(setf current): Public generic functions
(setf current): Public generic functions
(setf index): Public generic functions
(setf index): Public generic functions
(setf iterator): Public generic functions
(setf iterator): Public generic functions
(setf iterator): Public generic functions
(setf limit): Public generic functions
(setf limit): Public generic functions
(setf object): Public generic functions
(setf object): Public generic functions
(setf prefetch): Public generic functions
(setf prefetch): Public generic functions
(setf prefetch): Public generic functions
(setf start): Public generic functions
(setf start): Public generic functions
(setf total-length): Public generic functions
(setf total-length): Public generic functions

B
binding: Public ordinary functions
bindings-for-gens: Private ordinary functions
buffer: Public generic functions
buffer: Public generic functions
buffer: Public generic functions

C
clause: Public ordinary functions
close-stream: Public generic functions
close-stream: Public generic functions
close-stream: Public generic functions
collect-for-values: Private ordinary functions
compute-binding-parts: Private ordinary functions
compute-declaration-parts: Private ordinary functions
convert-bindings: Private ordinary functions
convert-clauses: Private ordinary functions
copy-list*: Private ordinary functions
current: Public generic functions
current: Public generic functions

D
define-accumulation-binding: Public macros
define-alias-binding: Public macros
define-direct-binding: Public macros
define-direct-clause: Private macros
define-form-binding: Public macros
define-form-symbol-macro-binding: Public macros
define-simple-clause: Private macros
define-value-binding: Public macros
define-value-symbol-macro-binding: Public macros
delist: Private ordinary functions

E
emit-binding-definition: Private ordinary functions
end: Public generic functions
end: Public generic functions
end: Public generic functions
end: Public generic functions
enlist: Private ordinary functions

F
for: Public macros
Function, (setf binding): Public ordinary functions
Function, (setf clause): Public ordinary functions
Function, binding: Public ordinary functions
Function, bindings-for-gens: Private ordinary functions
Function, clause: Public ordinary functions
Function, collect-for-values: Private ordinary functions
Function, compute-binding-parts: Private ordinary functions
Function, compute-declaration-parts: Private ordinary functions
Function, convert-bindings: Private ordinary functions
Function, convert-clauses: Private ordinary functions
Function, copy-list*: Private ordinary functions
Function, delist: Private ordinary functions
Function, emit-binding-definition: Private ordinary functions
Function, enlist: Private ordinary functions
Function, hash-table-iterator: Public ordinary functions
Function, normalize-declaration-inner: Private ordinary functions
Function, normalize-declarations: Private ordinary functions
Function, package-iterator: Public ordinary functions
Function, remove-binding: Public ordinary functions
Function, remove-bindings: Private ordinary functions
Function, remove-clause: Public ordinary functions
Function, replace-lambda-vars: Private ordinary functions
Function, translate-form-vars: Private ordinary functions

G
Generic Function, (setf buffer): Public generic functions
Generic Function, (setf close-stream): Public generic functions
Generic Function, (setf current): Public generic functions
Generic Function, (setf index): Public generic functions
Generic Function, (setf iterator): Public generic functions
Generic Function, (setf limit): Public generic functions
Generic Function, (setf object): Public generic functions
Generic Function, (setf prefetch): Public generic functions
Generic Function, (setf start): Public generic functions
Generic Function, (setf total-length): Public generic functions
Generic Function, buffer: Public generic functions
Generic Function, close-stream: Public generic functions
Generic Function, current: Public generic functions
Generic Function, end: Public generic functions
Generic Function, has-more: Public generic functions
Generic Function, index: Public generic functions
Generic Function, iterator: Public generic functions
Generic Function, limit: Public generic functions
Generic Function, make-iterator: Public generic functions
Generic Function, next: Public generic functions
Generic Function, object: Public generic functions
Generic Function, prefetch: Public generic functions
Generic Function, start: Public generic functions
Generic Function, step-functions: Public generic functions
Generic Function, total-length: Public generic functions

H
has-more: Public generic functions
has-more: Public generic functions
has-more: Public generic functions
has-more: Public generic functions
has-more: Public generic functions
has-more: Public generic functions
has-more: Public generic functions
has-more: Public generic functions
has-more: Public generic functions
has-more: Public generic functions
hash-table-iterator: Public ordinary functions

I
index: Public generic functions
index: Public generic functions
initialize-instance: Public standalone methods
initialize-instance: Public standalone methods
initialize-instance: Public standalone methods
initialize-instance: Public standalone methods
initialize-instance: Public standalone methods
initialize-instance: Public standalone methods
initialize-instance: Public standalone methods
iterator: Public generic functions
iterator: Public generic functions
iterator: Public generic functions

L
limit: Public generic functions
limit: Public generic functions
limit: Public generic functions

M
Macro, define-accumulation-binding: Public macros
Macro, define-alias-binding: Public macros
Macro, define-direct-binding: Public macros
Macro, define-direct-clause: Private macros
Macro, define-form-binding: Public macros
Macro, define-form-symbol-macro-binding: Public macros
Macro, define-simple-clause: Private macros
Macro, define-value-binding: Public macros
Macro, define-value-symbol-macro-binding: Public macros
Macro, for: Public macros
Macro, unwind-protect*: Private macros
Macro, update: Public macros
Macro, values*: Private macros
Macro, with-for-block: Private macros
Macro, with-for-tagbody: Private macros
Macro, with-interleaving: Public macros
make-iterator: Public generic functions
make-iterator: Public generic functions
make-iterator: Public generic functions
make-iterator: Public generic functions
make-iterator: Public generic functions
make-iterator: Public generic functions
make-iterator: Public generic functions
make-iterator: Public generic functions
make-iterator: Public generic functions
make-iterator: Public generic functions
Method, (setf buffer): Public generic functions
Method, (setf buffer): Public generic functions
Method, (setf close-stream): Public generic functions
Method, (setf close-stream): Public generic functions
Method, (setf current): Public generic functions
Method, (setf current): Public generic functions
Method, (setf current): Public generic functions
Method, (setf current): Public generic functions
Method, (setf current): Public generic functions
Method, (setf current): Public generic functions
Method, (setf current): Public generic functions
Method, (setf current): Public generic functions
Method, (setf current): Public generic functions
Method, (setf index): Public generic functions
Method, (setf iterator): Public generic functions
Method, (setf iterator): Public generic functions
Method, (setf limit): Public generic functions
Method, (setf object): Public generic functions
Method, (setf prefetch): Public generic functions
Method, (setf prefetch): Public generic functions
Method, (setf start): Public generic functions
Method, (setf total-length): Public generic functions
Method, buffer: Public generic functions
Method, buffer: Public generic functions
Method, close-stream: Public generic functions
Method, close-stream: Public generic functions
Method, current: Public generic functions
Method, end: Public generic functions
Method, end: Public generic functions
Method, end: Public generic functions
Method, has-more: Public generic functions
Method, has-more: Public generic functions
Method, has-more: Public generic functions
Method, has-more: Public generic functions
Method, has-more: Public generic functions
Method, has-more: Public generic functions
Method, has-more: Public generic functions
Method, has-more: Public generic functions
Method, has-more: Public generic functions
Method, index: Public generic functions
Method, initialize-instance: Public standalone methods
Method, initialize-instance: Public standalone methods
Method, initialize-instance: Public standalone methods
Method, initialize-instance: Public standalone methods
Method, initialize-instance: Public standalone methods
Method, initialize-instance: Public standalone methods
Method, initialize-instance: Public standalone methods
Method, iterator: Public generic functions
Method, iterator: Public generic functions
Method, limit: Public generic functions
Method, limit: Public generic functions
Method, make-iterator: Public generic functions
Method, make-iterator: Public generic functions
Method, make-iterator: Public generic functions
Method, make-iterator: Public generic functions
Method, make-iterator: Public generic functions
Method, make-iterator: Public generic functions
Method, make-iterator: Public generic functions
Method, make-iterator: Public generic functions
Method, make-iterator: Public generic functions
Method, next: Public generic functions
Method, next: Public generic functions
Method, next: Public generic functions
Method, next: Public generic functions
Method, next: Public generic functions
Method, next: Public generic functions
Method, next: Public generic functions
Method, next: Public generic functions
Method, next: Public generic functions
Method, next: Public generic functions
Method, object: Public generic functions
Method, prefetch: Public generic functions
Method, prefetch: Public generic functions
Method, start: Public generic functions
Method, step-functions: Public generic functions
Method, step-functions: Public generic functions
Method, step-functions: Public generic functions
Method, step-functions: Public generic functions
Method, step-functions: Public generic functions
Method, step-functions: Public generic functions
Method, step-functions: Public generic functions
Method, step-functions: Public generic functions
Method, step-functions: Public generic functions
Method, step-functions: Public generic functions
Method, total-length: Public generic functions

N
next: Public generic functions
next: Public generic functions
next: Public generic functions
next: Public generic functions
next: Public generic functions
next: Public generic functions
next: Public generic functions
next: Public generic functions
next: Public generic functions
next: Public generic functions
next: Public generic functions
normalize-declaration-inner: Private ordinary functions
normalize-declarations: Private ordinary functions

O
object: Public generic functions
object: Public generic functions

P
package-iterator: Public ordinary functions
prefetch: Public generic functions
prefetch: Public generic functions
prefetch: Public generic functions

R
remove-binding: Public ordinary functions
remove-bindings: Private ordinary functions
remove-clause: Public ordinary functions
replace-lambda-vars: Private ordinary functions

S
start: Public generic functions
start: Public generic functions
step-functions: Public generic functions
step-functions: Public generic functions
step-functions: Public generic functions
step-functions: Public generic functions
step-functions: Public generic functions
step-functions: Public generic functions
step-functions: Public generic functions
step-functions: Public generic functions
step-functions: Public generic functions
step-functions: Public generic functions
step-functions: Public generic functions

T
total-length: Public generic functions
total-length: Public generic functions
translate-form-vars: Private ordinary functions

U
unwind-protect*: Private macros
update: Public macros

V
values*: Private macros

W
with-for-block: Private macros
with-for-tagbody: Private macros
with-interleaving: Public macros


A.4 Data types

Jump to:   A   B   C   D   F   H   I   L   P   R   S   T   V  
Index Entry  Section

A
array-iterator: Public classes

B
binding.lisp: The for/binding․lisp file

C
Class, array-iterator: Public classes
Class, directory-iterator: Public classes
Class, hash-table-iterator: Public classes
Class, iterator: Public classes
Class, list-iterator: Public classes
Class, package-iterator: Public classes
Class, random-iterator: Public classes
Class, sequence-iterator: Public classes
Class, stream-iterator: Public classes
Class, stream-line-iterator: Public classes
Class, vector-iterator: Public classes
clause.lisp: The for/clause․lisp file

D
directory-iterator: Public classes
documentation.lisp: The for/documentation․lisp file

F
File, binding.lisp: The for/binding․lisp file
File, clause.lisp: The for/clause․lisp file
File, documentation.lisp: The for/documentation․lisp file
File, for.asd: The for/for․asd file
File, for.lisp: The for/for․lisp file
File, iterator.lisp: The for/iterator․lisp file
File, package.lisp: The for/package․lisp file
File, standard.lisp: The for/standard․lisp file
File, toolkit.lisp: The for/toolkit․lisp file
for: The for system
for: The for package
for-iterator: The for-iterator package
for-minimal: The for-minimal package
for.asd: The for/for․asd file
for.lisp: The for/for․lisp file

H
hash-table-iterator: Public classes

I
iterator: Public classes
iterator.lisp: The for/iterator․lisp file

L
list-iterator: Public classes

P
Package, for: The for package
Package, for-iterator: The for-iterator package
Package, for-minimal: The for-minimal package
package-iterator: Public classes
package.lisp: The for/package․lisp file

R
random-iterator: Public classes

S
sequence-iterator: Public classes
standard.lisp: The for/standard․lisp file
stream-iterator: Public classes
stream-line-iterator: Public classes
System, for: The for system

T
toolkit.lisp: The for/toolkit․lisp file

V
vector-iterator: Public classes