emacs-devel
[Top][All Lists]
Advanced

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

Re: [ANN] New library stream.el in ELPA


From: Nicolas Petton
Subject: Re: [ANN] New library stream.el in ELPA
Date: Wed, 14 Oct 2015 18:20:06 +0200
User-agent: Notmuch/0.19 (http://notmuchmail.org) Emacs/25.0.50.7 (x86_64-unknown-linux-gnu)

John Wiegley <address@hidden> writes:

> How bizarre, just yesterday I started a file called "thunks.el" to generalize
> this kind of behavior. Since I didn't get very far, I'm glad to see the idea
> taking shape elsewhere!
>
> What I wonder is, can you generalize this beyond cons cells?  I mean, can we
> have a general lazy evaluation framework, instead of just lazy lists?  The API
> I was thinking of was:
>
>     (let ((x (thunk-create FORM)))
>       (thunk-eval x))
>
> The idea being that 'x' is a self-modifying thunk which only evaluates FORM
> the first time it is forced, but immediately returns the result value after.
>
> I think that stream-cons and seq-take could be implemented on top of this
> lower-level behavior.

stream.el is based on lazy form evaluation with memoization (which is
exactly what you describe IIUC), that I didn't need to expose it so I
kept it private to the library, see `stream--delay' and `stream-force':

https://github.com/NicolasPetton/stream/blob/master/stream.el#L62

Nico

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]