Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the generators Reference Manual, version 0.1, generated automatically by Declt version 3.0 "Montgomery Scott" on Mon Apr 19 16:11:05 2021 GMT+0.
• Introduction | What generators 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 |
Generators is a library that provides python style generators in common lisp, by using cl-cont delimited continuations
This library is more of an interesting toy, though as far as I know it does work. I dont think I have ever used this in application code, though I think that with care, it could be.
Continuations don't play nicely with exception/signal handling, unwind-protect, throw/catch, or dynamic variables. Consider using cl-cont:without-call/cc, if you need this functionality in a generator. (see-also %mv-gen for an example)
because cl-cont uses a code walker, it might get confused when interacting other code walkers (eg: iterate). Inside of generators, you might have better luck with less code walking
Creates a new generator, the body of which can yield values to the calling scope
yield - returns the next value from the generator to the caller
yielding - yields every value in the passed in generators
iterates through the values produced by a generator
iterates through all the nodes of a lisp tree eg: '(1 (2 3) 4) generates (1 (2 3) 2 3 4)
iterates through all the leaves of a lisp tree eg: '(1 (2 3) 4) generates (1 2 3 4)
(defun generate-lisp-tree-nodes (trees &optional leaves-only?)
"Do a depth first traversal of some set of trees yielding every node/leaf "
(make-generator ()
(iter (for n in (alexandria:ensure-list trees))
(etypecase n
(atom (yield n))
(list
(unless leaves-only? (yield n))
(yielding (generate-lisp-tree-nodes n)))))))
;; Copyright (c) 2013 Russ Tyndall , Acceleration.net http://www.acceleration.net
;; All rights reserved.
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are
;; met:
;;
;; - Redistributions of source code must retain the above copyright
;; notice, this list of conditions and the following disclaimer.
;;
;; - Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Next: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The generators system |
BSD
A common lisp package providing python style generators based on delimited continuations
0.1
generators.asd (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
• The generators.asd file | ||
• The generators/packages.lisp file | ||
• The generators/generators.lisp file |
Next: The generators/packages․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
generators.asd
generators (system)
Next: The generators/generators․lisp file, Previous: The generators․asd file, Up: Lisp files [Contents][Index]
generators (system)
packages.lisp
Previous: The generators/packages․lisp file, Up: Lisp files [Contents][Index]
generators (system)
generators.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The generators.system package | ||
• The generators package |
Next: The generators package, Previous: Packages, Up: Packages [Contents][Index]
generators.asd
Previous: The generators․system package, Up: Packages [Contents][Index]
packages.lisp (file)
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 conditions | ||
• Exported classes |
Next: Exported functions, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
returns a function that when called yields the next values. Inside of
body, you can yield any number of values that you wish by calling
(yield &rest args) which is scoped to the body
generators.lisp (file)
Next: Exported generic functions, Previous: Exported macros, Up: Exported definitions [Contents][Index]
Do a depth first traversal of some set of trees yielding every node
generators.lisp (file)
Next: Exported conditions, Previous: Exported functions, Up: Exported definitions [Contents][Index]
Forces the generator to produce a list of its output
generators.lisp (file)
generators.lisp (file)
Returns the next value of this generator
generators.lisp (file)
Restarts the generator from its original continuation
generators.lisp (file)
Next: Exported classes, Previous: Exported generic functions, Up: Exported definitions [Contents][Index]
generators.lisp (file)
error (condition)
:generator
(quote nil)
generator (generic function)
(setf generator) (generic function)
:handled?
(quote nil)
handled? (generic function)
(setf handled?) (generic function)
Previous: Exported conditions, Up: Exported definitions [Contents][Index]
A class that stores all the needed structure for a generator
generators.lisp (file)
standard-object (class)
The current continuation of the generator
:continuation
continuation (generic function)
(setf continuation) (generic function)
Should this generator, generate a sigil value when complete
if nil will raise the final-exception (defaults ’stop-iteration)
:use-final-value?
use-final-value? (generic function)
(setf use-final-value?) (generic function)
The value to generate if we are using a final-value instead of raising exceptions
:final-value
final-value (generic function)
(setf final-value) (generic function)
An exception to raise when we are done iterating (if not using final-value)
:final-exception
(quote generators:stop-iteration)
final-exception (generic function)
(setf final-exception) (generic function)
Has this generator generated all values?
:finished?
finished? (generic function)
(setf finished?) (generic function)
The starting point of this generator
:original-continuation
original-continuation (generic function)
(setf original-continuation) (generic function)
:name
name (generic function)
(setf name) (generic function)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal macros | ||
• Internal functions | ||
• Internal generic functions |
Next: Internal functions, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
generators.lisp (file)
generators.lisp (file)
generators.lisp (file)
Next: Internal generic functions, Previous: Internal macros, Up: Internal definitions [Contents][Index]
Generates a value from the generator, if the generator throws
stop iteration returns (values nil T),
turns off call/cc so that this works
generators.lisp (file)
generators.lisp (file)
generators.lisp (file)
Previous: Internal functions, Up: Internal definitions [Contents][Index]
The current continuation of the generator
generators.lisp (file)
An exception to raise when we are done iterating (if not using final-value)
generators.lisp (file)
The value to generate if we are using a final-value instead of raising exceptions
generators.lisp (file)
Has this generator generated all values?
generators.lisp (file)
generators.lisp (file)
automatically generated reader method
generators.lisp (file)
automatically generated writer method
generators.lisp (file)
The starting point of this generator
generators.lisp (file)
Should this generator, generate a sigil value when complete
if nil will raise the final-exception (defaults ’stop-iteration)
generators.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 G L |
---|
Jump to: | F G L |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | %
(
C F G H M N O R U |
---|
Jump to: | %
(
C F G H M N O R U |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | C F G H N O S U |
---|
Jump to: | C F G H N O S U |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | C G P S |
---|
Jump to: | C G P S |
---|