CLJ-1454 and CLJ-1599 - deref-swap! / deref-reset!

170 views
Skip to first unread message

Alex Miller

unread,
Feb 29, 2016, 9:44:30 AM2/29/16
to Clojure Dev
I'd like to get these tickets cleaned up enough to have Rich consider. 

Current state:
  • CLJ-1454 Add deref-swap! (swap! that returns prior value)
    • Needs a patch
  • CLJ-1599 Add deref-reset! (reset! that returns old value)
    • Ticket description needs to be cleaned up and simplified
    • Patch should use deref-reset! name to match CLJ-1454
Perhaps, these two tickets and patches should be combined? I presume the patches are likely to conflict so that might make it easier.

Linus Ericsson

unread,
Feb 29, 2016, 12:19:38 PM2/29/16
to cloju...@googlegroups.com
Alex,

I added a patch addressing these two issues by adding deref- methods to the IAtom (breaking!) and quite straightforward implementations of the reset (from get-and-set.diff of Steven Yi) and a simple search and replace of the variable names in the derefSwap versions. I renamed "v" in the swap implementation to "oldv" for clarity on the return row.

I added the patch in CLJ-1454.

I guess you have to consider if the breaking of IAtom.java is worth it. Other implementations avoiding this interface change is certainly possible.

/Linus

--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-dev...@googlegroups.com.
To post to this group, send email to cloju...@googlegroups.com.
Visit this group at https://groups.google.com/group/clojure-dev.
For more options, visit https://groups.google.com/d/optout.

Alex Miller

unread,
Feb 29, 2016, 12:58:52 PM2/29/16
to cloju...@googlegroups.com
Another option is to add a subinterface to IAtom (or a secondary interface) like IAtomPrior for the new methods. These functions could then rely on that interface and other existing IAtom impls could retrofit when they like. 

Or this could simply be a breaking change. I know of only a couple cases where people requested IAtom to exist with ideas to use it.

Steven Yi

unread,
Mar 1, 2016, 8:18:33 AM3/1/16
to Clojure Dev
I saw that 1599 was closed and tracking taken over in 1454 which works for me. The description I filed for 1599 was a bit verbose; I could go back to simplify it if that would be of value to someone; otherwise, I'll leave it as-is. 

Thanks,
steven

Alex Miller

unread,
Mar 1, 2016, 8:36:10 AM3/1/16
to cloju...@googlegroups.com
I was planning to do some work on it today to simplify it. :)
--

Steven Yi

unread,
Mar 1, 2016, 8:47:55 AM3/1/16
to cloju...@googlegroups.com
That's great, thanks Alex!

steven
> You received this message because you are subscribed to a topic in the
> Google Groups "Clojure Dev" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojure-dev/_ixXNiIyiuQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to

Alex Miller

unread,
Mar 11, 2016, 3:27:49 PM3/11/16
to Clojure Dev
Many thanks to Linus for getting this work into good shape too!
> To post to this group, send email to cloju...@googlegroups.com.
> Visit this group at https://groups.google.com/group/clojure-dev.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Clojure Dev" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojure-dev/_ixXNiIyiuQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
Reply all
Reply to author
Forward
0 new messages