On Wed, Sep 23, 2009 at 4:18 PM, Roger Gilliar <ro...@gilliar.de> wrote:
> I have the following code: > > (defn handle-client [in out] > (binding [ > *in* (reader in) > ] > (with-connection db > (let [outstream (agent (writer out))] > (loop [] > (let [xml (read-input)] > (if xml > (do > > (send-answers (parse outstream (makestr xml))) > (recur)) > (info > "disconnected")))))))) > > > The problem is, that it doesn't work to assign an agent to the > outstream. If I do, the content of the agent (the outstream in this > case) is set to nil after it is passed to send-answers and all send- > answers does is to store the agent in a struct. Why that ? > Wrapping a mutable thing like an output stream in an agent seems dubious to me. Then you don't dereference it -- you pass the agent itself to parse as its first argument, rather than the stream it wraps. That might not have been what you intended. Try just dropping the (agent ...) around (writer out). --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---