Created
April 20, 2015 18:57
-
-
Save mfikes/c9842b04392a2b6f7d4e to your computer and use it in GitHub Desktop.
Nashorn volatiles in terms of atoms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ git diff | |
| diff --git a/src/cljs/cljs/core.cljs b/src/cljs/cljs/core.cljs | |
| index 2794acc..4f69f06 100644 | |
| --- a/src/cljs/cljs/core.cljs | |
| +++ b/src/cljs/cljs/core.cljs | |
| @@ -3882,18 +3882,18 @@ reduces them without incurring seq initialization" | |
| [iref] | |
| (.-validator iref)) | |
| -(deftype Volatile [^:mutable state] | |
| +(deftype Volatile [state] | |
| IVolatile | |
| (-vreset! [_ new-state] | |
| - (set! state new-state)) | |
| + (reset! state new-state)) | |
| IDeref | |
| - (-deref [_] state)) | |
| + (-deref [_] @state)) | |
| (defn volatile! | |
| "Creates and returns a Volatile with an initial value of val." | |
| [val] | |
| - (Volatile. val)) | |
| + (Volatile. (atom val))) | |
| (defn volatile? | |
| "Returns true if x is a volatile." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment