Quick Clojure by Mark McDonnell

Quick Clojure by Mark McDonnell

Author:Mark McDonnell
Language: eng
Format: epub
Publisher: Apress, Berkeley, CA


The delay function prevents an action from happening straight away. It is asynchronous until the point of being dereferenced, whereby it will block until the behavior has completed . Once a delay has been executed, it will cache its return value (see Listing 8-1 for example).

(def later (delay (prn "hello")))

;; returns immediately and doesn't block

;; ...some point later in your application...

@later ;; nil (prints "hello")

@later ;; nil (notice no "hello" is printed this time)

Listing 8-1.Example of Using delay



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.