Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the for Reference Manual, version 1.0.0, generated automatically by Declt version 2.4 "Will Decker" on Wed Jun 20 11:47:49 2018 GMT+0.
• Introduction: | What for is all about | |
• Systems: | The systems documentation | |
• Files: | The files documentation | |
• Packages: | The packages documentation | |
• Definitions: | The symbols documentation | |
• Indexes: | Concepts, functions, variables and data types |
For is a library for an extensible iteration macro. It allows you to write concise looping constructs similar to loop
and iterate
. Unlike loop however it is extensible and sensible, and unlike iterate it does not require code-walking and is easier to extend.
Load For using ASDF or Quicklisp.
(ql:quickload :for)
Now we can use the for
macro to do iteration. Most of the constructs you know from loop
are available with the same name in For.
(for:for ((li in (list 1 2 3 4))
(vi across #(a b c d)))
(format T "~&~a ~a" li vi))
In loop
this might look as follows:
(loop for li in (list 1 2 3 4)
for vi across #(a b c d)
do (format T "~&~a ~a" li vi))
Unlike loop
and iterate
, for
makes a distinction between "bindings" and body forms. Body forms can also contain clauses:
(for:for ((li in (list 1 2 3 4)))
(thereis (evenp li)))
In loop
this might look as follows:
(loop for li in (list 1 2 3 4)
thereis (evenp li))
Naturally, there's also accumulation bindings:
(for:for ((randoms collecting (random 10)))
(until (= 10 (length randoms))))
In loop
this might look as follows:
(loop collect (random 10) into randoms
until (= 10 (length randoms)))
You might realise that the above is a rather inefficient way of writing the loop. Instead we can also use the repeat
binding:
(for:for ((i repeat 10)
(randoms collecting (random 10))))
In loop
this might look as follows:
(loop repeat 10
collect (random 10))
If we have multiple bindings or clauses that might have useful values to return, all of them are returned:
(for:for ((a over *random-state* :limit 10)
(b collect a))
(thereis (evenp a)))
In loop
this might look as follows:
(loop with iterator = (for-iterator:make-iterator *random-state* :limit 10)
while (for-iterator:has-more iterator)
for a = (for-iterator:next iterator)
collect a into b
when (evenp a)
return (values T b))
In order for short-circuiting clauses to have highest priority on values, clause-values are always returned first followed by binding values. Otherwise the order follows the declaration order of the respective clauses/bindings. Note that clauses must appear as a "top-level" form within the for
body and cannot appear as the result of a macroexpansion.
For also features a generic iterator construct that allows you to iterate over a multitude of different data types without having to do a case-distinction by yourself. We already saw this with the over *random-state*
binding from the previous example.
(for:for ((a over '(1 2 3))
(b over #(a b c))
(c over (for:for ((table as (make-hash-table)))
(setf (gethash (random 10) table) (random 10)) (repeat 3)))
(d over *package*)
(e over *random-state*)
(f over (directory (merge-pathnames "*.*" (user-homedir-pathname))))
(g over (make-string-input-stream "Hi!")))
(print (list a b c d e f g)))
Note that the over
iterator construct can be drastically slower than a tailored iteration construct.
Some iterators also support updating the current element. If you require doing so, you can use the updating
binding.
(for:for ((list as (list 1 2 3 4 5))
(item updating list))
(setf item (expt item item)))
In loop
this might look as follows:
(loop with list = (list 1 2 3 4 5)
with iterator = (for-iterator:make-iterator list)
while (for-iterator:has-more iterator)
do (for-iterator:next iterator)
(symbol-macrolet ((item (for-iterator:current iterator)))
(setf item (expt item item)))
finally (return list))
Some of the bindings also support destructuring the current item by a destructuring-lambda-list.
(for:for (((type &key object limit) in '((counter :limit 5)
(package :object *package*))))
(format T "~&Type: ~a~@[ Object: ~a~]~@[ Limit: ~a~]" type object limit))
In loop
this might look as follows:
(loop for list in '((counter :limit 5)
(package :object *package*))
do (destructuring-bind (type &key object limit) list
(format T "~&Type: ~a~@[ Object: ~a~]~@[ Limit: ~a~]" type object limit)))
You can check a binding's or clause's documentation with (documentation 'in 'for:binding)
which will tell you whether it supports destructuring through update
.
Sometimes you may want to iterate over multiple things in sequence rather than in parallel. For this you can use the being
binding, which allows you to pass a list of sub-bindings to sequentially use.
(for:for (((k v) being
(in '((駅 station) (出口 exit) (特急 express-train)))
(across #((勉強 studying) (宿題 home-work) (授業 lesson) (試験 exam)))))
(format T "~&~a: ~a" k v))
In loop
this might look as follows:
(progn (loop for (k v) in '((駅 station) (出口 exit) (特急 express-train))
do (format T "~&~a: ~a" k v))
(loop for (k v) across #((勉強 studying) (宿題 home-work) (授業 lesson) (試験 exam))
do (format T "~&~a: ~a" k v)))
If a binding should only be updated based on a condition, there's the when
and unless
bindings that defer based on a test.
(for:for ((random = (random 10))
(list when (evenp random) collect random))
(until (= 10 (length list))))
In loop
this might look as follows:
(loop with list = ()
for random = (random 10)
when (evenp random)
do (push random list)
until (= 10 (length list))
finally (return (nreverse list)))
The following bindings are included in the for-minimal
package:
=
across
appending
/ append
as
being
collecting
/ collect
counting
/ count
from
in
lines-of
maximizing
/ maximize
minimizing
/ minimize
nconcing
/ nconc
on
over
ranging
/ range
reducing
/ reduce
repeating
/ repeat
summing
/ sum
symbols
table-keys
table-pairs
table-values
unless
updating
/ update
when
The following clauses are included in the for-minimal
package:
always
never
returning
thereis
until
while
Iterator classes for the following types is included in the for-iterator
package:
list
vector
array
stream
pathname
random-state
package
hash-table
each item is a list of key and value.Both bindings and clauses are defined in terms of functions that return three values:
with-interleaving
.Passed to the functions are the literal arguments used in the binding or clause expression. In that way, a clause/binding function must work just like a macro would.
The most primitive way to define bindings is through the define-direct-binding
macro. This defines a verbatim binding function as described above. Note that the loop body forms of bindings will always be evaluated before the proper for body.
In most cases you will want the arguments that are passed to the binding to be evaluated only once, before the loop starts properly. The define-value-binding
macro will help you with that. Each argument you specify will be bound to a gensym within the definition body, and is automatically expanded to a variable with the value that is used in the binding. &aux
arguments receive special treatment as they are expanded like regular variables and thus allow you to easily define helper variables necessary during iteration.
Let's look at an example binding definition:
(define-value-binding across (var vector &aux (i -1) (length (length vector)))
`(if (= ,length (incf ,i))
(end-for)
(update ,var (aref ,vector ,i))))
Expanding a simple call (for ((a across vec)))
results in this expansion (after cleaning it up a little):
(LET* ((#:VECTOR VEC)
(#:I -1)
(#:LENGTH (LENGTH #:VECTOR))
(A NIL))
(WITH-FOR-BODY
(IF (= #:LENGTH (INCF #:I))
(END-FOR)
(UPDATE A (AREF #:VECTOR #:I))))
As you can see, our only argument, vector
got expanded into a gensym-ed variable that is bound to the result of the vector
argument. Our auxiliary variables received similar treatment. Note that references to other arguments automatically get translated to their proper gensyms.
In some cases however you'd like to re-evaluate an argument each iteration. To get this behaviour, you can use define-form-binding
. Here's a simple example:
(define-form-binding = (var form)
`(update ,var ,form))
Expanding a simple call (for ((a = (* 2 2))))
presents us with:
(LET* ((A NIL))
(WITH-FOR-BODY
(UPDATE A (* 2 2)))
Usually you will want form bindings if you want to accumulate the results of it over time in some manner. In that case you usually also want to return the result of the accumulation once you're done. define-accumulation-binding
does exactly that. One note about form bindings is that the auxiliary variables still act the same as in the value bindings-- they automatically get expanded to bindings in the resulting loop construct.
Let's look at an example that shows both:
(define-accumulation-binding collecting (var form &aux (head (cons NIL NIL)) (tail head))
`(setf ,tail (setf (cdr ,tail) (cons ,form NIL))
,var (cdr ,head)))
Expanding (for ((a collecting 2)))
results in:
(LET* ((#:HEAD (CONS NIL NIL)) (#:TAIL #:HEAD) (A NIL))
(WITH-FOR-BODY
(SETF #:TAIL (SETF (CDR #:TAIL) (CONS 2 NIL))
A (CDR #:HEAD))
(RETURN-FOR A))
As before, the auxiliary arguments got expanded to variable bindings with their respective default values.
Finally we have two variants of form and value bindings, define-form-symbol-macro-binding
and define-value-symbol-macro-binding
. The difference to the previous definition forms here is that the var
is not bound as a variable, but instead as a symbol macro. Its default value is the symbol-macro expansion. This is useful if you want to provide an updateable place as the iteration var, as is the case with the updating
binding.
Clauses work the exact same as bindings in terms of the base function, which you can define with define-direct-clause
. Unlike bindings however, clauses simply get the body of their call as arguments, without an iteration var.
In order to ease things a bit there is also define-simple-clause
which provides the same handling for arguments as define-form-binding
does.
One thing to note is that the surrounding forms of clauses always appear deeper than those of bindings and that the result value forms of clauses always appear before those of bindings. The loop body form of a clause appears at the exact position in the body where the clause expression previously appeared.
In order to provide the generic over
iteration construct, For includes a protocol to define iterators. In order for an iterator to work, it has to subclass iterator
and provide three methods: make-iterator
, has-more
, and next
. The first is merely there so that we can dispatch on the type of object we'd like to iterate over and construct an appropriate iterator for it. The second should return a generalised boolean that tells us whether we can safely call next
. Finally, next
itself advances the iterator and returns a new element. If sensible and possible, a method on (setf current)
can also be provided to allow updating the current element to a new value.
Let's look at the list iterator as an example:
(defclass list-iterator (iterator)
())
(defmethod initialize-instance :after ((iterator list-iterator) &key object)
(setf (object iterator) (cons NIL object)))
(defmethod has-more ((iterator list-iterator))
(cdr (object iterator)))
(defmethod next ((iterator list-iterator))
(setf (object iterator) (cdr (object iterator)))
(car (object iterator)))
(defmethod (setf current) (value (iterator list-iterator))
(setf (car (object iterator)) value))
(defmethod make-iterator ((list list) &key)
(make-instance 'list-iterator :object list))
First we subclass iterator
. Next we define an initialize method in order to prepend a cons to the list. We do this so that we know the next element will always be in the cadr of the object
and we can still set the car of the current cons cell to update it. The has-more
test is implemented accordingly. On next
we then simply pop off the first cons and return our new current element. The (setf current)
can then just update the car of the object
. Finally we
Next: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The for system: |
Nicolas Hafner <shinmera@tymoon.eu>
Nicolas Hafner <shinmera@tymoon.eu>
Artistic
An extensible iteration macro library.
1.0.0
for.asd (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files: |
Next: The for/package<dot>lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
for.asd
for (system)
Next: The for/toolkit<dot>lisp file, Previous: The for<dot>asd file, Up: Lisp files [Contents][Index]
for (system)
package.lisp
Next: The for/binding<dot>lisp file, Previous: The for/package<dot>lisp file, Up: Lisp files [Contents][Index]
package.lisp (file)
for (system)
toolkit.lisp
Next: The for/clause<dot>lisp file, Previous: The for/toolkit<dot>lisp file, Up: Lisp files [Contents][Index]
toolkit.lisp (file)
for (system)
binding.lisp
Next: The for/for<dot>lisp file, Previous: The for/binding<dot>lisp file, Up: Lisp files [Contents][Index]
binding.lisp (file)
for (system)
clause.lisp
Next: The for/iterator<dot>lisp file, Previous: The for/clause<dot>lisp file, Up: Lisp files [Contents][Index]
clause.lisp (file)
for (system)
for.lisp
for (macro)
Next: The for/standard<dot>lisp file, Previous: The for/for<dot>lisp file, Up: Lisp files [Contents][Index]
for.lisp (file)
for (system)
iterator.lisp
Next: The for/documentation<dot>lisp file, Previous: The for/iterator<dot>lisp file, Up: Lisp files [Contents][Index]
iterator.lisp (file)
for (system)
standard.lisp
Previous: The for/standard<dot>lisp file, Up: Lisp files [Contents][Index]
standard.lisp (file)
for (system)
documentation.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The for package: | ||
• The for-minimal package: | ||
• The for-iterator package: |
Next: The for-minimal package, Previous: Packages, Up: Packages [Contents][Index]
package.lisp (file)
org.shirakumo.for
Next: The for-iterator package, Previous: The for package, Up: Packages [Contents][Index]
package.lisp (file)
org.shirakumo.for.minimal
common-lisp
Previous: The for-minimal package, Up: Packages [Contents][Index]
package.lisp (file)
org.shirakumo.for.iterator
common-lisp
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions: | ||
• Internal definitions: |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported macros: | ||
• Exported functions: | ||
• Exported generic functions: | ||
• Exported classes: |
Next: Exported functions, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
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
binding.lisp (file)
Defines an alias for a binding.
See BINDING
binding.lisp (file)
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.
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
binding.lisp (file)
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
binding.lisp (file)
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
binding.lisp (file)
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
binding.lisp (file)
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
binding.lisp (file)
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
for.lisp (file)
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.
toolkit.lisp (file)
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.
toolkit.lisp (file)
Next: Exported generic functions, Previous: Exported macros, Up: Exported definitions [Contents][Index]
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
binding.lisp (file)
(setf binding) (function)
binding.lisp (file)
binding (function)
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
clause.lisp (file)
(setf clause) (function)
clause.lisp (file)
clause (function)
Returns a function to iterate over a hash-table.
See CL:WITH-HASH-TABLE-ITERATOR
toolkit.lisp (file)
Returns a function to iterate over a package’s symbols.
See CL:WITH-PACKAGE-ITERATOR
toolkit.lisp (file)
Removes the given binding function.
See BINDING
binding.lisp (file)
Removes the given clause function.
See CLAUSE
clause.lisp (file)
Next: Exported classes, Previous: Exported functions, Up: Exported definitions [Contents][Index]
Accessor to the stream-iterator’s buffer.
See STREAM-ITERATOR
(setf buffer) (generic function)
automatically generated reader method
iterator.lisp (file)
automatically generated reader method
iterator.lisp (file)
buffer (generic function)
automatically generated writer method
iterator.lisp (file)
automatically generated writer method
iterator.lisp (file)
Accessor to whether the stream should be closed on END call or not.
See STREAM-ITERATOR
See STREAM-LINE-ITERATOR
(setf close-stream) (generic function)
automatically generated reader method
iterator.lisp (file)
automatically generated reader method
iterator.lisp (file)
close-stream (generic function)
automatically generated writer method
iterator.lisp (file)
automatically generated writer method
iterator.lisp (file)
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
iterator.lisp (file)
(setf current) (generic function)
automatically generated reader method
iterator.lisp (file)
current (generic function)
automatically generated writer method
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.
iterator.lisp (file)
Returns a generalised boolean indicating whether the iterator has more items or not.
iterator.lisp (file)
Accessor to the current index within the buffer.
See STREAM-ITERATOR
(setf index) (generic function)
automatically generated reader method
iterator.lisp (file)
index (generic function)
automatically generated writer method
iterator.lisp (file)
Accessor to the amount of data that is currently filled in the buffer.
See STREAM-ITERATOR
(setf limit) (generic function)
automatically generated reader method
iterator.lisp (file)
automatically generated reader method
iterator.lisp (file)
limit (generic function)
automatically generated writer method
iterator.lisp (file)
Create an iterator object for the given type of object.
iterator.lisp (file)
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
iterator.lisp (file)
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
(setf object) (generic function)
automatically generated reader method
iterator.lisp (file)
object (generic function)
automatically generated writer method
iterator.lisp (file)
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
(setf prefetch) (generic function)
automatically generated reader method
iterator.lisp (file)
automatically generated reader method
iterator.lisp (file)
prefetch (generic function)
automatically generated writer method
iterator.lisp (file)
automatically generated writer method
iterator.lisp (file)
Accessor to the index that points to the next element of the vector-iterator.
(setf start) (generic function)
automatically generated reader method
iterator.lisp (file)
start (generic function)
automatically generated writer method
iterator.lisp (file)
Slot holding the array-total-size.
See ARRAY-ITERATOR
(setf total-length) (generic function)
automatically generated reader method
iterator.lisp (file)
total-length (generic function)
automatically generated writer method
iterator.lisp (file)
Previous: Exported generic functions, Up: Exported definitions [Contents][Index]
Iterator for general arrays.
Iteration is in row-major order.
Supports setting the current element.
See VECTOR-ITERATOR
See TOTAL-LENGTH
iterator.lisp (file)
vector-iterator (class)
total-length (generic function)
(setf total-length) (generic function)
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
iterator.lisp (file)
list-iterator (class)
initialize-instance (method)
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
iterator.lisp (file)
iterator (class)
prefetch (generic function)
(setf prefetch) (generic function)
An iterator is responsible for iterating over a given data structure.
See HAS-MORE
See NEXT
See CURRENT
See MAKE-ITERATOR
See OBJECT
iterator.lisp (file)
standard-object (class)
:object
object (generic function)
(setf object) (generic function)
current (generic function)
(setf current) (generic function)
Iterator for proper lists.
Supports setting the current element.
See ITERATOR
iterator.lisp (file)
iterator (class)
directory-iterator (class)
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
iterator.lisp (file)
iterator (class)
prefetch (generic function)
(setf prefetch) (generic function)
Initarg | Value |
---|---|
:status | (quote (:internal :external :inherited)) |
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
iterator.lisp (file)
iterator (class)
:limit
limit (generic function)
Initarg | Value |
---|---|
:limit | 1.0 |
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
iterator.lisp (file)
iterator (class)
buffer (generic function)
(setf buffer) (generic function)
1
index (generic function)
(setf index) (generic function)
1
limit (generic function)
(setf limit) (generic function)
:close-stream
close-stream (generic function)
(setf close-stream) (generic function)
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
iterator.lisp (file)
iterator (class)
buffer (generic function)
(setf buffer) (generic function)
:close-stream
close-stream (generic function)
(setf close-stream) (generic function)
Iterator for vectors.
Supports setting the current element.
See START
See ITERATOR
iterator.lisp (file)
iterator (class)
array-iterator (class)
:start
start (generic function)
(setf start) (generic function)
Initarg | Value |
---|---|
:start | 0 |
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal special variables: | ||
• Internal macros: | ||
• Internal functions: |
Next: Internal macros, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
binding.lisp (file)
clause.lisp (file)
This variable will be bound to the environment object during the expansion of the FOR macro.
standard.lisp (file)
Next: Internal functions, Previous: Internal special variables, Up: Internal definitions [Contents][Index]
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
clause.lisp (file)
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
clause.lisp (file)
toolkit.lisp (file)
The same idea as LIST* except for values.
toolkit.lisp (file)
Wraps the body in a looping block.
This establishes a NIL block.
See RETURN-FOR
Wraps the body in a looping tagbody, running the EXIT forms when the loop ends.
See END-FOR
See SKIP-FOR
Previous: Internal macros, Up: Internal definitions [Contents][Index]
binding.lisp (file)
toolkit.lisp (file)
binding.lisp (file)
binding.lisp (file)
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
binding.lisp (file)
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
clause.lisp (file)
Same as COPY-LIST, but also returning the last cons of the new list as a second value.
toolkit.lisp (file)
If A is a list, return the element that KEY retrieves.
toolkit.lisp (file)
binding.lisp (file)
If A is not a list, turn it into one with the given ELS as further items.
toolkit.lisp (file)
binding.lisp (file)
binding.lisp (file)
standard.lisp (file)
Replaces all VARS in LAMBDA-LIST with the NEW-VAR at the same position.
toolkit.lisp (file)
binding.lisp (file)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index: | ||
• Function index: | ||
• Variable index: | ||
• Data type index: |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | F L |
---|
Jump to: | F L |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | (
B C D E F G H I L M N O P R S T U V W |
---|
Jump to: | (
B C D E F G H I L M N O P R S T U V W |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | *
B C I L O P S T |
---|
Jump to: | *
B C I L O P S T |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | A C D F H I L P R S V |
---|
Jump to: | A C D F H I L P R S V |
---|