Clojure

IAtom interface

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Release 1.6
  • Fix Version/s: Release 1.7
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code
  • Approval:
    Vetted

Description

Atom and the other reference types do not have interfaces and are marked final.

Alternative IAtom implementations make sense for certain database abstractions.

Rich said "patch welcome for IAtom". See IRC logs: http://clojure-log.n01se.net/date/2010-12-29.html#10:04c

  1. 0001-atom-interface.patch
    28/May/11 3:39 AM
    3 kB
    Pepijn de Vos
  2. iatom.patch
    27/May/11 8:57 AM
    3 kB
    Pepijn de Vos

Activity

Hide
Stuart Halloway added a comment -

Please add a patch formatted by "git format-patch" so that attribution is included.

Show
Stuart Halloway added a comment - Please add a patch formatted by "git format-patch" so that attribution is included.
Hide
Pepijn de Vos added a comment -

I added the formatted patch a few days ago. Does 'no news is good news' apply here?

And, silly question, will it make it into 1.3? I can't figure out how to tell Jira to show me that.

Show
Pepijn de Vos added a comment - I added the formatted patch a few days ago. Does 'no news is good news' apply here? And, silly question, will it make it into 1.3? I can't figure out how to tell Jira to show me that.
Hide
Kevin Downey added a comment -

I fail to see the need for an IAtom, if you want something atom like for couchdb the interfaces are already there. Maybe I ICompareAndSwap. Atoms and couchdb are different so making them appear the same is a bad idea.

http://en.wikipedia.org/wiki/Fallacies_of_Distributed_Computing

http://clojure.org/state one of the distinctions between agents and actors raised in the section titled "Message Passing and Actors" is local vs. distributed and the same distinction can be made between couchdb (regardless of compare and swap) and atoms

Show
Kevin Downey added a comment - I fail to see the need for an IAtom, if you want something atom like for couchdb the interfaces are already there. Maybe I ICompareAndSwap. Atoms and couchdb are different so making them appear the same is a bad idea. http://en.wikipedia.org/wiki/Fallacies_of_Distributed_Computing http://clojure.org/state one of the distinctions between agents and actors raised in the section titled "Message Passing and Actors" is local vs. distributed and the same distinction can be made between couchdb (regardless of compare and swap) and atoms
Hide
Aaron Bedra added a comment -

This ticket has already been moved into approved backlog. It will be revisited again after the 1.3 release where we will take a closer look at things. For now, this will remain as is.

Show
Aaron Bedra added a comment - This ticket has already been moved into approved backlog. It will be revisited again after the 1.3 release where we will take a closer look at things. For now, this will remain as is.
Hide
Aaron Craelius added a comment -

Any chance this patch could get implemented in an upcoming Clojure release. There is still continued interest, see this thread: https://groups.google.com/forum/#!topic/clojure-dev/y5QoMqd44Lc

One suggestion I would make is also removing the final marker from clojure.lang.Atom - I can see use cases where one would want to directly subclass Atom (to capture dependencies in reactive computations for instance).

Show
Aaron Craelius added a comment - Any chance this patch could get implemented in an upcoming Clojure release. There is still continued interest, see this thread: https://groups.google.com/forum/#!topic/clojure-dev/y5QoMqd44Lc One suggestion I would make is also removing the final marker from clojure.lang.Atom - I can see use cases where one would want to directly subclass Atom (to capture dependencies in reactive computations for instance).
Hide
Brandon Bloom added a comment -

I'd like to see an IAtom interface, but would prefer that `swap` not be part of it. Swapping can, and should, be defined in terms of `compareAndSet`. Seems like IAtom should only have `boolean compareAndSet(object oldval, object newval)` as well as `void reset(object newval)`.

Show
Brandon Bloom added a comment - I'd like to see an IAtom interface, but would prefer that `swap` not be part of it. Swapping can, and should, be defined in terms of `compareAndSet`. Seems like IAtom should only have `boolean compareAndSet(object oldval, object newval)` as well as `void reset(object newval)`.
Hide
Brandon Bloom added a comment - - edited

Alternative patch that introduces IAtom and converts swap to be static.

Show
Brandon Bloom added a comment - - edited Alternative patch that introduces IAtom and converts swap to be static.
Hide
Pepijn de Vos added a comment -

At the time I did the initial patch, I had the same idea to remove swap, but Rich said there where cases for having it, so it should stay in according to him.

Show
Pepijn de Vos added a comment - At the time I did the initial patch, I had the same idea to remove swap, but Rich said there where cases for having it, so it should stay in according to him.
Hide
Aaron Craelius added a comment -

One use case I can think of for overriding swap is if an IAtom is wrapping say a row of data stored in a database. Then comparing something like a version column (or transaction id in the case of datomic) is what should determine whether a swap is retried, not the actual value of the data. In this case then, compareAndSet would actually be a more complex operation than swap and it makes sense to define the two independently.

Show
Aaron Craelius added a comment - One use case I can think of for overriding swap is if an IAtom is wrapping say a row of data stored in a database. Then comparing something like a version column (or transaction id in the case of datomic) is what should determine whether a swap is retried, not the actual value of the data. In this case then, compareAndSet would actually be a more complex operation than swap and it makes sense to define the two independently.
Hide
Aaron Craelius added a comment -

I should also mention my related issue: http://dev.clojure.org/jira/browse/CLJ-1470 which simply allows Atom (and also ARef) to be sub-classed. Both patches could ultimately work together to make the whole Atom/ARef infrastructure easier to extend.

Show
Aaron Craelius added a comment - I should also mention my related issue: http://dev.clojure.org/jira/browse/CLJ-1470 which simply allows Atom (and also ARef) to be sub-classed. Both patches could ultimately work together to make the whole Atom/ARef infrastructure easier to extend.
Hide
Alex Miller added a comment -

This ticket needs some work before it can be screened:

  • description can lose the the Couch stuff
  • needs some mention of tradeoffs for the various swap alternatives
  • don't know what patch should be considered
Show
Alex Miller added a comment - This ticket needs some work before it can be screened:
  • description can lose the the Couch stuff
  • needs some mention of tradeoffs for the various swap alternatives
  • don't know what patch should be considered
Hide
Brandon Bloom added a comment -

I removed my patch because Pepijn/Rich is right: Swap should be part of the interface.

Show
Brandon Bloom added a comment - I removed my patch because Pepijn/Rich is right: Swap should be part of the interface.

People

Vote (4)
Watch (5)

Dates

  • Created:
    Updated: