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