You can use @x as shorthand for (force x) too, since delays implement
IDeref.
On Oct 20, 1:25 pm, Paul Richards wrote:
> On 20 October 2010 21:21, Paul Richards wrote:
>
>
>
> > On 20 October 2010 20:45, Paul Richards wrote:
> >> On 20 October 2010 20:23, Alan wrote:
> >>> Augh no, future is n
On 20 October 2010 21:21, Paul Richards wrote:
> On 20 October 2010 20:45, Paul Richards wrote:
>> On 20 October 2010 20:23, Alan wrote:
>>> Augh no, future is not lazy; it's for multithreading. Try delay - it's
>>> identical to the (suspend) given by the OP.
>>>
>>> user=> (time (def x (delay (
On 20 October 2010 20:45, Paul Richards wrote:
> On 20 October 2010 20:23, Alan wrote:
>> Augh no, future is not lazy; it's for multithreading. Try delay - it's
>> identical to the (suspend) given by the OP.
>>
>> user=> (time (def x (delay (Thread/sleep 1
>> "Elapsed time: 0.256312 msecs
On 20 October 2010 20:23, Alan wrote:
> Augh no, future is not lazy; it's for multithreading. Try delay - it's
> identical to the (suspend) given by the OP.
>
> user=> (time (def x (delay (Thread/sleep 1
> "Elapsed time: 0.256312 msecs"
> #'user/x
> user=> (time (force x))
> "Elapsed time:
Augh no, future is not lazy; it's for multithreading. Try delay - it's
identical to the (suspend) given by the OP.
user=> (time (def x (delay (Thread/sleep 1
"Elapsed time: 0.256312 msecs"
#'user/x
user=> (time (force x))
"Elapsed time: 1.19261 msecs"
See also promise/deliver:
user=>
user=> (doc future)
-
clojure.core/future
([& body])
Macro
Takes a body of expressions and yields a future object that will
invoke the body in another thread, and will cache the result and
return it on all subsequent calls to deref/@. If the computation has
not yet f