Details
-
Type:
Defect
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Declined
-
Affects Version/s: Release 1.3, Release 1.4
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
Description
The :unsynchronized-mutable fields of a deftype cannot be set! inside a try block that is not in tail position of the method.
See file *demonstration.clj* for an complete code example.
Attachments
Activity
Rich Hickey
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Assignee | Rich Hickey [ richhickey ] |
Timothy Baldridge
made changes -
| Resolution | Declined [ 2 ] | |
| Status | Open [ 1 ] | Closed [ 6 ] |
I looked at this. The problem is that non-tail try blocks turn into closures, and thus the field gets propagated as a constant. IOW this can't work:
(deftype Foo4 [^:unsynchronized-mutable x] MutableX (set-x [this v] ((fn [] (set! x v))) v))I'm not going to re-evaluate the try/closure approach right now, so I recommend you make a helper method that just does the assignment and then call that in the bigger context, as a workaround.
(deftype Foo4 [^:unsynchronized-mutable x] MutableX (set-x [this v] ((fn [] (set! x v))) v))