EDIT: After posting a previous version of my question, I found that the real problem is with nested functions.
If I have a closure inside deftype , I cannot update any mutable fields from this closure.
eg. following works:
(deftype Test [^:unsynchronized-mutable x] TestInterface (perform [this o] (set! xo)))
but this is not so:
(deftype Test [^:unsynchronized-mutable x] TestInterface (perform [this o] (fn [] (set! xo)) nil)) ; throws a compiler error about assigning to non-mutable field
Is there a way to reach and access the field? Running (set! (.x this) o) results in:
ClassCastException user.Test cannot be passed to compile__stub.user.Test user.Test / fn-152 (NO_SOURCE_FILE: 3
When trying to run code.
Code for TestInterface for completeness:
(definterface TestInterface (perform [o]))
source share