On Nov 29, 2013, at 11:58 AM, Sam Ritchie <sritchi...@gmail.com> wrote:

> 2) a defstatefn macro that defines the "mark" and "mark!" versions at the 
> same time.

I do that with agents:

(def-action text :send [state number message])

… creates a `text*` and a `text>!`, where `test>!` is

(defn text>! [number message] (send self text* number message))

A nice bit about this is that `text*` is pure, so easily testable. Since 
`text>!` is constructed, I'm happy not testing it. Since I use Midje 
prerequisites to test that the `>!`-style functions are called when 
appropriate, I get nicely decoupled unit tests that don't have to know they're 
working with agents (except that the `>!` functions always return irrelevant 
values.)

I haven't been using this style for long, but it feels right so far.

--------
Latest book: /Functional Programming for the Object-Oriented Programmer/
https://leanpub.com/fp-oo

-- 
-- 
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/groups/opt_out.

Reply via email to