[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: thunk.el: Document that thunk-force == funcall?
From: |
Stefan Monnier |
Subject: |
Re: thunk.el: Document that thunk-force == funcall? |
Date: |
Tue, 17 Nov 2020 16:51:22 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Michael Heerdegen [2020-11-17 16:17:14] wrote:
> The background: because thunks are functions, one is allowed (and it is
> useful) to directly pass them to higher order functions e.g. as a test
> predicate, or bind them using `cl-flet', or `cl-letf' to a
> `symbol-function' place. Currently, the official solution would require
> to use a lambda wrapper.
I like the idea that we could replace the current representation with
something more like a `defstruct`, so I'm on the side of "don't document
that thunks *are* functions", but it's not a very strong opinion.
In any case even without documenting them to be functions, we could
provide
(defalias 'thunk-function #'identity)
to avoid the wasteful use of a lambda wrapper.
> I have encountered this requirement several times (and using `thunk-let'
> was not always the solution) - thus my question.
[...]
> Say the code loops over a list of files or so (not known at think time).
> The thunk could "contain" a test that might take long (e.g. something
> that might need to look at the file's contents) but the result is
> interesting only sometimes, depending on the result of other tests (also
> not known at think time).
[ That's still pretty hypothetical. ]
I'd be curious to see concrete examples, to get a better idea of
the tradeoffs.
Stefan
Re: thunk.el: Document that thunk-force == funcall?,
Stefan Monnier <=