*Background*
I am starting on a port of my Common Lisp Cells dataflow hack 
<https://github.com/kennytilton/cells> (much akin to Javelin 
<https://github.com/hoplon/javelin> in surface semantics) to Clojure and am 
struggling to wrap my head around Clojure state-handling, deftype, and 
defrecord.

Development will be in my Jellz repository 
<https://github.com/kennytilton/jellz>, which for now just holds a "Cells 
Lite" common lisp 
<https://github.com/kennytilton/jellz/blob/master/src/jellz/jellz.lisp> 
hack similar to something I once tossed off without thinking during a 
presentation to Jay Sulzberger's Linux group.

*Question*
Cells uses a lot of state internally to keep track of dependencies and 
more, so I need state. Now how do I best do that The Clojure way?

I think I am in good shape, from what I have read so far, because any given 
state change at the higher abstraction of the application model (eg, "this 
text-edit widget keypress slot just got a new value" already works in a way 
amenable to STM, including The Restart Problem:

   1. We already have a global **pulse** value (serial integer) that 
   manages consistency during propagation of the *input cell* keypress 
   across the larger model. So *pulse* becomes one ref, yes?
   2. Within dosynch:
      1. Increment *pulse*
      2. Now all dependent values (mediated by *formula cells*) get 
      recalculated recursively. Anyone trying to mutate state need to do so 
only 
      to refs. (Updating state in a formula is weird, but on rare occasions I 
      close over a variable to see a bit of history.)
      3. Invoke any observers:
         1. If these guys mutate state, they better be refs
         2. These can also write to input cells (think "falling dominoes") 
         but are required to do so by enqueueing them for FIFO execution 
immediately 
         after this one pulse has been fully executed. 
      3. The above may restart, but as long as everything is a ref we are 
   good. Yes?
   4. Internally, the cell data structure must also be composed of refs. I 
   am thinking I will just make an array of refs. Is that fastest?
   5. Now each cell currently serves as the slot value of a CLOS object 
   wired with a few extra slots to support Cells. These too would be refs, I 
   am guessing, though instead of class objects these would just be maps. Yes?

How'm I doin'?

Thx, hk

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to