Re: Suspensions

2010-10-20 Thread Alan
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

Re: Suspensions

2010-10-20 Thread Paul Richards
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 (

Re: Suspensions

2010-10-20 Thread Paul Richards
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

Re: Suspensions

2010-10-20 Thread Paul Richards
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:

Re: Suspensions

2010-10-20 Thread Alan
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=>

Re: Suspensions

2010-10-20 Thread Albert Cardona
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