Created
February 23, 2010 21:43
-
-
Save astrangeguy/312749 to your computer and use it in GitHub Desktop.
This file contains 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
(deftype Bench [#^{:unsynchronized-mutable true} val] | |
Runnable | |
(run [] (let [a 1 b 2] | |
(set! val a) | |
(dotimes [_ 10] | |
(time (dotimes [_ 10000000] | |
(set! val a) | |
(set! val b))))))) | |
Cannot assign to non-mutable: val | |
[Thrown class java.lang.IllegalArgumentException] | |
Restarts: | |
0: [ABORT] Return to SLIME's top level. | |
Backtrace: | |
0: clojure.lang.Compiler$ObjExpr.emitAssignLocal(Compiler.java:4022) | |
1: clojure.lang.Compiler$LocalBindingExpr.emitAssign(Compiler.java:4590) | |
2: clojure.lang.Compiler$AssignExpr.emit(Compiler.java:438) | |
3: clojure.lang.Compiler$BodyExpr.emit(Compiler.java:4668) | |
4: clojure.lang.Compiler$IfExpr.emit(Compiler.java:2218) | |
5: clojure.lang.Compiler$BodyExpr.emit(Compiler.java:4671) | |
6: clojure.lang.Compiler$LetExpr.emit(Compiler.java:4940) | |
7: clojure.lang.Compiler$BodyExpr.emit(Compiler.java:4671) | |
8: clojure.lang.Compiler$ObjMethod.emit(Compiler.java:4422) | |
... | |
and another one: | |
(deftype Bench [#^{:unsynchronized-mutable true} val] | |
:as this | |
Runnable | |
(run [] (let [a 1 b 2] | |
(set! (.val this) a) | |
(dotimes [_ 10] | |
(time (dotimes [_ 10000000] | |
(set! (.val this) a) | |
(set! (.val this) b))))))) | |
(.run (Bench 1)) | |
user.Bench__4583 cannot be cast to compile__stub.user.Bench__4583 | |
[Thrown class java.lang.ClassCastException] | |
Restarts: | |
0: [ABORT] Return to SLIME's top level. | |
Backtrace: | |
0: user.Bench__4583.run(NO_SOURCE_FILE:1) | |
1: sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
2: sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) | |
3: sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
4: java.lang.reflect.Method.invoke(Method.java:616) | |
5: clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:90) | |
6: clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:265) | |
7: user$eval__4607.invoke(NO_SOURCE_FILE:1) | |
8: clojure.lang.Compiler.eval(Compiler.java:5358) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment