Hi,

Am 05.03.2009 um 10:13 schrieb bOR_:

Is there a reason why delay needs a force to be calculated?

delay creates a Delay object (Promise in Scheme). This can be
passed around like eg. a Vector. When you want to retrieve the
value, you have to use force, like get for a map. The first time
the original value gets evaluated and the result gets cached.
Subsequent calls to force then simply returns this cached result.

I use Delays in my lazy-map package to provide a map, which
evaluates the value of the keys lazily only when the user really
accesses them. This is transparent to the code.

  (def x (lazy-hash-map :a (some-calculation) :b (other-calculation)))
  (x :a) ; <- no some-calculation happens
(dissoc x :b) ; <- other-calculation never happens, because not accessed

However to provide such transparent usage, needed some
plumbing around the Delays.

Sincerely
Meikel

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to