[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Making sure I'm not checking email (or doing other things) too often
From: |
Michael Heerdegen |
Subject: |
Re: Making sure I'm not checking email (or doing other things) too often |
Date: |
Sun, 06 Mar 2016 14:39:46 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.92 (gnu/linux) |
Marcin Borkowski <mbork@mbork.pl> writes:
> (defun create-stopwatch ()
> "Return a closure which returns time (in seconds) since its
> last invocation every time it is called."
> (let (last-invocation-time (current-time))
> (lambda ()
> (prog1
> (time-to-seconds (time-subtract (current-time) last-invocation-time))
> (setq last-invocation-time (current-time))))))
>
> I don't claim it to be better, but I noticed a strange phenomenon. When
> I invoke the "stopwatch object" (closure, in fact) for the first time,
> I get negative result. Why is that so?
Eehm, eh...looks like your let bindings are not what you intended...
Ask the byte compiler!
Regards,
Michael.