Hi Rich,
Wow, that's a comprehensive answer. Thanks.
I am using runonce to create lancet, a build system that ties into
Java's Ant. Build steps definitely do have side effects, so I will
probably end up using the agent approach. Targets don't have (or
ignore) return values, so I could igno
On Nov 9, 8:21 am, Stuart Halloway <[EMAIL PROTECTED]> wrote:
> You should be able to do this without the ref. Have the agent's state
> contain a pair of [has-run, fn-result].
The semantics of your runonce aren't clear to me, but here are some
strategies:
As Chouser proposed, if you only want a
You should be able to do this without the ref. Have the agent's state
contain a pair of [has-run, fn-result].
Stuart
> Hi,
>
> Am 09.11.2008 um 12:23 schrieb Stuart Halloway:
>> Just to make things even more fun: *None* of the proposed fixes to
>> the
>> concurrency bug in the original actua
Hi,
Am 09.11.2008 um 12:23 schrieb Stuart Halloway:
Just to make things even more fun: *None* of the proposed fixes to the
concurrency bug in the original actually preserve the` semantics of
the original. All have moved from "run (usually) once, mark as done"
to "mark as done, try once". This al
One way to think about the difference between alter and commute: With
a commutative function, they both get to the same end result, but
commute allows more concurrency, while guaranteeing less about the
return value. In particular, with commute you might not be able to see
every step by lo
On Nov 8, 2008, at 10:23 PM, Stuart Halloway wrote:
>
> How about:
>
> (defn runonce
> "Create a function that will only run its argument once."
> [function]
> (let [call-count (ref 0)]
> (fn [& args]
> (when (= 1 (dosync (alter call-count inc)))
> (apply function args)))
On Sat, Nov 8, 2008 at 10:23 PM, Stuart Halloway
<[EMAIL PROTECTED]> wrote:
>
> How about:
>
> (defn runonce
> "Create a function that will only run its argument once."
> [function]
> (let [call-count (ref 0)]
> (fn [& args]
> (when (= 1 (dosync (alter call-count inc)))
> (
How about:
(defn runonce
"Create a function that will only run its argument once."
[function]
(let [call-count (ref 0)]
(fn [& args]
(when (= 1 (dosync (alter call-count inc)))
(apply function args)
> On Nov 8, 2008, at 8:31 PM, Stuart Halloway wrote:
>
>>
>> T
On Nov 8, 2008, at 8:31 PM, Stuart Halloway wrote:
>
> The defrunonce macro below works, creating a function that runs only
> once and tracking its run status in metadata.
>
> Now, how do I write it without using eval?
>
> (defn runonce
> "Create a function that will only run once, given a fun
Excellent, thanks!
Stuart
On Sat, Nov 8, 2008 at 8:31 PM, Stuart Halloway
>
> <[EMAIL PROTECTED]> wrote:
>>
>> (defmacro defrunonce [sym doc & forms]
>> "Defines a function with runonce semantics. Curren run status
>> is kept in a reference under the :has-run metadata key."
>> (let [[function
On Sat, Nov 8, 2008 at 8:31 PM, Stuart Halloway
<[EMAIL PROTECTED]> wrote:
>
> (defmacro defrunonce [sym doc & forms]
> "Defines a function with runonce semantics. Curren run status
> is kept in a reference under the :has-run metadata key."
> (let [[function has-run] (runonce (eval (concat (
The defrunonce macro below works, creating a function that runs only
once and tracking its run status in metadata.
Now, how do I write it without using eval?
(defn runonce
"Create a function that will only run once, given a function. Returns
a vector containing the function and the refer
12 matches
Mail list logo