Updated comments

This commit is contained in:
Ignacy Moryc 2012-09-23 15:49:00 +02:00
parent 8ffa96a712
commit 7fecd24dd6

View file

@ -1,20 +1,20 @@
(meditations (meditations
(let [agent-example (agent 10)] (let [agent-example (agent 10)]
"Creating an Agent is as simple as assigning it a value" "Creating an Agent is as simple as assigning a value to it"
(= __ (instance? clojure.lang.Agent agent-example)) (= __ (instance? clojure.lang.Agent agent-example))
"To get agent's value you dereference it" "To get agent's value you dereference it"
(= __ @agent-example) (= __ @agent-example)
"To change agent's value you use send function - you pass action and action's arguments to it. "To change agent's value you can use 'send' function. Send takes as parameters, agent, action and arguments,
Send function, returns immediately, but the action is prccessed in a separate thread and it's the result, it returns immediately but the action is prccessed in a separate thread and it's the result, of action,
of that action that gets assigned to agent's state" that gets assigned to agent's state"
(= __ (do (= __ (do
(send agent-example + 2) (send agent-example + 2)
@agent-example)) @agent-example))
"You can't just send a value to agent" "You can't just send a value to agent it needs to be a function"
(= __ (do (= __ (do
(set-error-mode! agent-example :continue) (set-error-mode! agent-example :continue)
(send agent-example 20) (send agent-example 20)