> > Having said which, I could have a function make-agent-state and spec > that, then the body of make-agent is just (agent (make-agent-state > ...initialisers...)) Is that what you're suggesting?
Ya, sorry, I didn't meant to sound like I was questioning why you needed to do X. This is what I was suggesting, to do the wrapping from the calling code. That also means you can set the spec as a validator on the agent also, so all updates on the state would get re-validated like tbc++ mentioned. On Friday, 17 November 2017 09:50:15 UTC-8, Peter Hull wrote: > > On Friday, 17 November 2017 16:53:57 UTC, Didier wrote: >> >> Why do you return an agent from a function? Can't you just return the map >> it conatains instead? And spec that? > > I want to write a function spec (s/fdef) for a function make-agent that > takes some initialisers and returns a new agent with its state set up. So I > need the agent to come out of the function, not just its state. > Having said which, I could have a function make-agent-state and spec > that, then the body of make-agent is just (agent (make-agent-state > ...initialisers...)) Is that what you're suggesting? > > tbc++ - good point, I was only looking for something in the spec namespace. > > Thanks all. > > > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
