Skip to content

Instantly share code, notes, and snippets.

@mattmoss
Created August 8, 2012 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattmoss/3297977 to your computer and use it in GitHub Desktop.
Save mattmoss/3297977 to your computer and use it in GitHub Desktop.
Why does x end with value 1 rather than 0?
(defn test-agent-restart []
(let [x (agent 0 :error-handler (fn [a ex] (println ex) (restart-agent a 0)))]
(println @x)
(send x inc)
(await x)
(println @x)
(send x (fn [_] (throw (Exception. "whatever"))))
(await x)
(println @x)))
@mattmoss
Copy link
Author

mattmoss commented Aug 8, 2012

Expected output:
0
1

0

Actual output:
0
1

1

@mattmoss
Copy link
Author

mattmoss commented Aug 8, 2012

Oops, replace # in previous comment with "#Exception java.lang.Exception: whatever"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment