emacs-devel
[Top][All Lists]
Advanced

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

Re: A generalization of `thunk-let'


From: Michael Heerdegen
Subject: Re: A generalization of `thunk-let'
Date: Sat, 09 Dec 2017 11:33:58 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

> Another way to do that is to create a new kind of object which is like
> a spreadsheet-cell: it comes with an expression to compute it, and
> remembers its current value.  Internally it also keeps track of the
> other spreadsheet-cells used during the computation of the current
> value (i.e. the dependencies are automatically tracked for you).

That's a nice in-between layer (and it also offers the most important
part - a package prefix!).  Do you already have an implementation?

> Here you'd need to something like
>
>     (let* ((a (make-sscell 1))
>            (b (make-sscell 2))
>            (sum-of-a-and-b
>             (make-sscell
>              (progn (message "Calculating %d + %d" a b)
>                     (+ (sscell-get a) (sscell-get b))))))
>       ...)

An advantage is that you don't have to make dependencies explicit
(though, they are still a bit explicit due to the necessary usage of
`sscell-get').

A disadvantage seems to be that the input variables (`a', `b') need to
be declared as sscells, though they don't have dependencies themselves.


> > ;; Dependencies can be recursive:
>
> > (let ((a 1)
> >       (b 2)
> >       (c 3))
> >   (dep-let ((a+b   (a b)   (+ a b))
> >             (a+b+c (a+b c) (+ a+b c)))
> >     (list a+b
> >           a+b+c
> >           (progn (setq a 10) a+b+c))))
>
> I'm not sure I see the recursion, here.  Are you talking about the fact
> that a+b+c depends on a but only mentions a+b in its dependencies?

Yes, exactly: I should have said "dependencies are resolved
recursively".


Regards,

Michael.



reply via email to

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