Re: [Scheme-reports] Formal Comment: what is the required behavior of 'lazy'? Eli Barzilay 29 Jun 2012 17:15 UTC

A few minutes ago, Alex Shinn wrote:
> On Fri, Jun 29, 2012 at 9:32 AM, Eli Barzilay <eli@barzilay.org> wrote:
> > Yesterday, Alex Shinn wrote:
> >> On Thu, Jun 28, 2012 at 1:39 AM, Eli Barzilay <eli@barzilay.org> wrote:
> >> > A few minutes ago, Alex Shinn wrote:
> >> >> On Thu, Jun 28, 2012 at 1:12 AM, Eli Barzilay <eli@barzilay.org> wrote:
> >> >> > With both present, there is an easy way to remember which one to
> >> >> > choose: `lazy'.
> >> >>
> >> >> `delay' is useful for many other things besides streams, where
> >> >> `lazy' would not be applicable.
> >> >
> >> > For example...?
> >>
> >> Do you honestly doubt that the concept of delayed
> >> evaluation has uses outside of a stream?
> >>
> >> In the most basic case it serves as a simple cache:
> >>
> >>   (let ((x (delay <expr>)))
> >>      ...
> >>      (if ... (force x) ...)
> >>      ...
> >>      (if ... (force x) ...))
> >>
> >> Lazy doesn't work here.
> >
> > *Some* `lazy's do.  I missed the fact that you've crippled `lazy'.
> > (It's an odd decision that not only makes it a more limited tool, it also
> > contradicts a dynamically typed language.)
>
> I'm only aware of one definition of `lazy' - the one from srfi-45
> and used by srfi-41.  If there is an alternative definition I'd like
> to know.

It's one that does not require to be used with a promise.

$ racket
Welcome to Racket v5.2.1.
-> (lazy 1)
#<promise:stdin:1:0>
-> (force ^)
1
-> (force (lazy (lazy 2)))
2

--
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports