Changeset 20931 in project


Ignore:
Timestamp:
10/22/10 04:43:14 (9 years ago)
Author:
Kon Lovett
Message:

Rel 3.1.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/srfi-45

    r19761 r20931  
    1616
    1717
    18 === Constructors
     18=== lazy
    1919
    20 ==== lazy
     20<macro>(lazy EXPRESSION) => promise</macro>
    2121
    22 <macro>(lazy EXPRESSION) => PROMISE</macro>
    23 
    24 Returns a promise for {{EXPRESSION}}.
     22Returns a promise for {{EXPRESSION}}, which must evaluate to a SRFI 45 promise.
     23(See {{lazy-strict}}.}
    2524
    2625The promise will be iteratively forced, overwriting the promise at each step
    2726before the next iteration, so as to avoid storage leaks.
    2827
    29 ==== eager
     28=== lazy-strict
    3029
    31 <procedure>(eager EXPRESSION) => PROMISE</procedure>
     30<procedure>(lazy-strict [STRICT?]) => boolean</procedure>
     31
     32The body {{EXPRESSION}} of a {{lazy}} promise must produce a result of type
     33{{promise}} according to SRFI 45. This is the default behavior of this
     34implementation. To accept a more lenient interpretation call with a value of
     35{{#f}} for {{STRICT?}}.
     36
     37The {{"improper use of `lazy'"}} error from {{force}} serves notice that a
     38lazy expression was not of the correct type.
     39
     40=== eager
     41
     42<macro>(eager EXPRESSION) => promise</macro>
    3243
    3344Returns a promise but immediately evaluates {{EXPRESSION}}.
    3445
    35 Not much of a promise, more of a boxed value. For exposition purposes in
    36 algorithms.
     46=== force
    3747
    38 ==== delay
     48<procedure>(force PROMISE) => OBJECT</procedure>
    3949
    40 <macro>(delay EXPRESSION) => PROMISE</macro>
     50Returns the result of the evaluation of {{PROMISE}}. When {{PROMISE}} is an R5RS
     51promise an R5RS {{force}} is performed and when {{PROMISE}} is not a promise it
     52is the result.
     53
     54=== delay
     55
     56<macro>(delay EXPRESSION) => promise</macro>
    4157
    4258Returns a SRFI-45 promise, a delayed evaluation of {{EXPRESSION}}.
    4359
     60=== lazy-promise?
    4461
    45 === Predicates
     62<procedure>(lazy-promise? OBJECT) => boolean</procedure>
    4663
    47 ==== promise?
     64=== eager-promise?
    4865
    49 <procedure>(promise? OBJECT) => BOOLEAN</procedure>
     66<procedure>(eager-promise? OBJECT) => boolean</procedure>
    5067
    51 Some kind of promise? An R5RS promise or a recursive promise.
     68=== recursive-promise?
    5269
    53 ==== recursive-promise?
     70<procedure>(recursive-promise? OBJECT) => boolean</procedure>
    5471
    55 <procedure>(recursive-promise? OBJECT) => BOOLEAN</procedure>
     72Is the {{OBJECT}} a recursive-promise; an eager or lazy promise?
    5673
    57 Recursive promise? A lazy or an eager promise.
     74=== promise?
    5875
    59 ==== lazy-promise?
     76<procedure>(promise? OBJECT) => boolean</procedure>
    6077
    61 <procedure>(lazy-promise? OBJECT) => BOOLEAN</procedure>
    62 
    63 ==== eager-promise?
    64 
    65 <procedure>(eager-promise? OBJECT) => BOOLEAN</procedure>
    66 
    67 
    68 === Operations
    69 
    70 ==== force
    71 
    72 <procedure>(force PROMISE) => OBJECT</procedure>
    73 
    74 Returns the result of the evaluation of {{PROMISE}}.
     78Some kind of promise? An R5RS promise or a recursive-promise.
    7579
    7680
     
    8185  ; Allow access to the original API and stop those annoying
    8286  ; redefined messages.
    83   (import (rename scheme (force r5rs:force) (delay r5rs:delay))
    84           (rename chicken (promise? r5rs:promise?))
    85           ...)
     87  (import
     88    (rename scheme (force r5rs:force) (delay r5rs:delay))
     89    (rename chicken (promise? r5rs:promise?))
     90    ...)
    8691  (use srfi-45)
    8792  ... code that can use R5RS and SRFI 45 promises ...
     
    9095
    9196
    92 == Examples
     97== Notes
    9398
     99* Supports multiple values for an eager promise and when {{(lazy-strict)}}
     100is {{#f}} for a lazy promise.
    94101
    95 == Notes
     102* If compiled with the feature {{srfi-45-paranoia}} defined then extra
     103sanity checks are enabled.
     104
     105* The built-in routines are ''not'' rebound. This is purely a module
     106implementation. As such the built-in {{promise?}} will not detect a
     107recursive-promise as a promise. Do not allow these abstractions to
     108''leak'' into unsuspecting contexts.
    96109
    97110
     
    99112
    100113None
    101 
    102 
    103 == Bugs and Limitations
    104114
    105115
     
    111121== Version history
    112122
     123; 3.1.0 : Added {{lazy-strict}} and compile-time feature {{srfi-45-paranoia}}. Better R5RS promise support by {{lazy}}.
    113124; 3.0.0 : Redefines {{delay}}. Removed {{d-lay}} and {{recursive-delay}}.
    114125; 2.2.0 : Bug fix for ''lazy'' R5RS promise in {{force}}. [Reported by Derrell Piper]
Note: See TracChangeset for help on using the changeset viewer.