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 10000))))
"Elapsed time: 0.256312 msecs"
#'user/x
user=> (time (force x))
"Elapsed time: 10000.19261 msecs"

See also promise/deliver:

user=> (def x (promise))
#'user/x
user=> @x
;; will never terminate because nobody delivers x
user=> (deliver x 95)
#<core$promise$reify__5...@1d4f279: 95>
user=> @x
95
user=> (deliver x 95)
java.lang.IllegalStateException: Multiple deliver calls to a promise
(NO_SOURCE_FILE:0)

On Oct 20, 12:16 pm, Albert Cardona <sapri...@gmail.com> wrote:
> 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 finished, calls to deref/@ will block.
>
> --http://albert.rierol.net

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to