[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] Formal Comment: what is the required behavior of 'lazy'?

On Thu, Jun 28, 2012 at 1:39 AM, Eli Barzilay <eli@x> wrote:
> A few minutes ago, Alex Shinn wrote:
>> On Thu, Jun 28, 2012 at 1:12 AM, Eli Barzilay <eli@x> 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.

An idiom I'ved used is macros which expand to delayed bindings:

  (letrec ((x (delay ... y ...))
             (y (delay ... z ...))
             (z (delay ... w ...)))

This allows arbitrary non-procedure values to refer to each
other directly without concern for the order they occur in
the original macro syntax (cycles are problematic but I used
this in a syntax where cycles were not meaningful).

A quick grep on my own source reveals about a dozen
other users, and I don't have time to categorize them all.

People were using delay for a long time before lazy came


Scheme-reports mailing list