You are looking at historical revision 15586 of this page. It may differ significantly from its current revision.

srfi-45

Primitives for Expressing Iterative Lazy Algorithms

Documentation

Extends the interpretation of a promise to include lazy and eager promises.

For more information see SRFI 45.

Constructors

lazy

[syntax] (lazy EXPRESSION) => PROMISE

Returns a promise for EXPRESSION.

The promise will be iteratively forced, overwriting the promise at each step before the next iteration, so as to avoid storage leaks.

eager

[procedure] (eager EXPRESSION) => PROMISE

Returns a promise but immediately evaluates EXPRESSION.

Not much of a promise, more of a boxed value. For exposition purposes in algorithms.

delay

[syntax] (delay EXPRESSION) => PROMISE

Returns an R5RS promise, a delayed evaluation of EXPRESSION.

d-lay

[syntax] (delay-recursive EXPRESSION) => PROMISE
[syntax] (d-lay EXPRESSION) => PROMISE

Returns a (lazy (eager EXPRESSION)) recursive promise.

This routine exists so the R5RS delay is not redefined.

Predicates

promise?

[procedure] (promise? OBJECT) => BOOLEAN

Some kind of promise? An R5RS promise or a recursive promise.

recursive-promise?

[procedure] (recursive-promise? OBJECT) => BOOLEAN

Recursive promise? A lazy or an eager promise.

lazy-promise?

[procedure] (lazy-promise? OBJECT) => BOOLEAN

eager-promise?

[procedure] (eager-promise? OBJECT) => BOOLEAN

Operations

force

[procedure] (force PROMISE) => OBJECT

Returns the result of the evaluation of PROMISE.

Usage

(require-library srfi-45)
...
(import srfi-45)

or

(require-extension srfi-45)

Examples

Notes

Requirements

None

Bugs and Limitations

Author

kon lovett

Version history

2.2.0
Bug fix for lazy R5RS promise in force. [Reported by Derrell Piper]
2.1.0
Bug fix for too eager force. Removed "box" extension dependency.
2.0.0
Chicken 4 release.

License

Copyright (C) 2009 Kon Lovett. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.