Hi there,
I've updated the apply-at docstring. Does the following make more sense?
"Scheduled function appliction. Works identically to apply, except
that it takes an additional initial argument: ms-time. If ms-time is
in the future, function application is delayed until that time, if
ms-time is in the past function application is immediate.
Can be used to immplement the 'temporal recursion' pattern. This is
where a function has a call to apply-at at its tail:
(defn foo
[t val]
(println val)
(let [next-t (+ t 200)]
(apply-at next-t #'foo [next-t (inc val)])))
(foo (now) 0) ;=> 0, 1, 2, 3...
The fn foo is written in a recursive style, yet the recursion is
scheduled for application 200ms in the future. By passing a function
using #'foo syntax instead of the symbole foo, when later called by
the scheduler it will lookup based on the symbol rather than using
the instance of the function defined earlier. This allows us to
redefine foo whilst the temporal recursion is continuing to execute."
Sam
---
http://sam.aaron.name