Please also note the existence of (future-call), which takes a no-arg fn instead of a body,
HTH, -- Laurent On 25 nov, 17:21, David Brown <cloj...@davidb.org> wrote: > On Tue, Nov 24, 2009 at 09:04:38PM -0800, Hong Jiang wrote: > >Hi all, > > >I'm new to Clojure and playing with small programs. Today I wrote a > >snippet to figure out how future works: > > >(defn testf [] > > (let [f (future #(do > > (Thread/sleep 5000) > > %) > > 5) > > g 7] > > (+ g @f))) > > You don't ever evaluate the function containing the sleep, you just > create it, and then immediately return 5. > > Future contains an explicit do, so you can just do the steps in the > future: > > [f (future > (Thread/sleep 5000) > 5) > ... > > Or, if you want to get the function call in, you'll need to call it: > > [f (future (#(do (Thread/sleep 5000) %) 5)) ...] > > David -- 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