On 30 July 2012 01:34, larry google groups <lawrencecloj...@gmail.com> wrote:
>
> I'll ask this differently. I do not see "a" used anywhere inside of that
> function. So why is it being given to that function?

I have not used send-off, but I think the answer is as follows:

When you call (send-off the-agent the-function), "the-function" gets
called with a single argument (which is the current value of the
agent).  That is why log-dumper has an argument.  Of course,
log-dumper does not use its argument, but it must still be there.
Perhaps it should have been called "dummy".

*agent* is the current agent.

You said that at the end *agent* is being passed to log-dumper.  This
is wrong.  The send-off call causes log-dumper to be called with the
contents/value of the agent.  Not with *agent*.

> On Tuesday, July 24, 2012 1:36:27 AM UTC-4, Philip Potter wrote:
>>
>> "a" is the current value of the agent. *agent* is the agent itself.
>>
>> Remember the universal update mechanism: an agent, atom or ref is updated
>> by applying a (normally) pure function to it; the function takes the current
>> state and returns the new state.
>>
>> Phil
>>
>> On Jul 24, 2012 5:16 AM, "larry google groups" <lawrencecloj...@gmail.com>
>> wrote:
>>>
>>>
>>> I am confused by this blog post:
>>>
>>>
>>> http://www.bestinclass.dk/index.clj/2009/09/php-vs-clojure-what-does-it-cost-to-be-old-school.html
>>>
>>> In particular, I am confuse by this function:
>>>
>>> (defn log-dumper
>>>   [a]
>>>   (Thread/sleep *write-delay*)
>>>   (let [sql-statements  (let [tmp @*sql-buffer*]
>>>                           (ref-set *sql-buffer* [])
>>>                            tmp)]
>>>     (doseq [stmt sql-statements]
>>>       (run *mysql-connection* stmt))
>>>     (send-off *agent* log-dumper)))
>>>
>>>
>>> It looks like "a" is being passed in as an argument to the function. But
>>> at the end of the function, *agent* is being passed into the function again.
>>> I don't see a point in this function where "a" is magically transformed into
>>> *agent*. I'm under the impression that this same agent is suppose to be
>>> sent, over and over again, every 5 minutes, for all eternity, into the
>>> function. But if the function is suppose to send the same agent to itself, 5
>>> minutes in the future, then I would think that if the argument is named "a"
>>> then "a" is what would be send-off to the function again.
>>>
>>> The blog post says:
>>>
>>> ""send-off" myself (the *agent* is the thread) to the same function
>>> again, ie. keep running."
>>>
>>> How does this work? How does the final line know that *agent* is the "a"
>>> that was passed in as an argument?
>>>
>>>
>>>
>>>
>>>
>>> --
>>> 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 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



-- 
Michael Wood <esiot...@gmail.com>

-- 
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

Reply via email to