[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: |
Marcin Borkowski |
Subject: |
Re: Making sure I'm not checking email (or doing other things) too often |
Date: |
Sun, 06 Mar 2016 15:09:52 +0100 |
User-agent: |
mu4e 0.9.13; emacs 25.1.50.6 |
On 2016-03-06, at 14:39, Michael Heerdegen <michael_heerdegen@web.de> wrote:
> 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...
Yeah, I hit C-c C-c too early...
> Ask the byte compiler!
The problem is, it didn't complain!
> Regards,
>
> Michael.
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University