On Jan 30, 4:35 pm, ataggart <alex.tagg...@gmail.com> wrote: > Akin to what Johann said, why bother with the functions that deal with > the value/state? Put another way, the cell has identity over time, > thus implemented as a ref. A function that, say, prints a cell, should > take a cell/ref as its arg.
This is my general approach with refs: most of the time, I treat the ref as the fundamental object. The biggest question there, for me at least, is how to come up with a good naming convention to distinguish functions that must be called from within a transaction from those that create the transaction themselves. So far, I've just been putting a comment at the start of each function that assumes a transaction, and that seems fine. The ref/state issue did just come up with me when trying to marshal some refs. When marshalling the ref, I have to store the pointer in a table, so if I come upon it again, I can just return a reference to it. Marshalling the state of the ref, however, is just deciding on my data representation. This led to two functions, which led to me scratching my head trying to figure out what I should name them. marshal-cell and marshal-cell-? marshal-cell-state? The state vs. "ref" question becomes more important, for me, with agents. I tend to spend about as much time manipulating the agent state as I do moving around the agents themselves and deciding which one to call, so it's less clear to me which one I should treat as fundamental. > Probably more than you need, but I highly recommend Rich's talk on the > subject of identity and > state:http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey I keep meaning to watch that, but I'm too impatient to watch most video on the internet. Clearly, I need a commute. -Johann -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en