From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Stuart D. Herring" Newsgroups: gmane.emacs.devel Subject: Re: Should `cancel-timer' use `delete' instead of `delq'? Date: Tue, 5 Sep 2006 12:13:43 -0700 (PDT) Message-ID: <33709.128.165.123.18.1157483623.squirrel@webmail.lanl.gov> References: Reply-To: herring@lanl.gov NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1157483687 6615 80.91.229.2 (5 Sep 2006 19:14:47 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 5 Sep 2006 19:14:47 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 05 21:14:44 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GKgNU-0007hs-Cr for ged-emacs-devel@m.gmane.org; Tue, 05 Sep 2006 21:14:32 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GKgNT-0003fF-Mx for ged-emacs-devel@m.gmane.org; Tue, 05 Sep 2006 15:14:31 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GKgNI-0003ew-9V for emacs-devel@gnu.org; Tue, 05 Sep 2006 15:14:20 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GKgNF-0003ec-Ei for emacs-devel@gnu.org; Tue, 05 Sep 2006 15:14:19 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GKgNF-0003eZ-BB for emacs-devel@gnu.org; Tue, 05 Sep 2006 15:14:17 -0400 Original-Received: from [192.65.95.54] (helo=mailwasher-b.lanl.gov) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GKgY2-0008WE-So for emacs-devel@gnu.org; Tue, 05 Sep 2006 15:25:27 -0400 Original-Received: from mailrelay3.lanl.gov (mailrelay3.lanl.gov [128.165.4.104]) by mailwasher-b.lanl.gov (8.13.6/8.13.6/(ccn-5)) with ESMTP id k85JDhKf002322 for ; Tue, 5 Sep 2006 13:13:44 -0600 Original-Received: from webmail1.lanl.gov (webmail1.lanl.gov [128.165.4.106]) by mailrelay3.lanl.gov (8.13.6/8.13.6/(ccn-5)) with ESMTP id k85JDhmw020914; Tue, 5 Sep 2006 13:13:43 -0600 Original-Received: from webmail1.lanl.gov (localhost.localdomain [127.0.0.1]) by webmail1.lanl.gov (8.12.11.20060308/8.12.11) with ESMTP id k85JDh16017855; Tue, 5 Sep 2006 13:13:43 -0600 Original-Received: (from apache@localhost) by webmail1.lanl.gov (8.12.11.20060308/8.12.11/Submit) id k85JDhVA017853; Tue, 5 Sep 2006 12:13:43 -0700 X-Authentication-Warning: webmail1.lanl.gov: apache set sender to herring@lanl.gov using -f Original-Received: from 128.165.123.18 (SquirrelMail authenticated user 196434) by webmail.lanl.gov with HTTP; Tue, 5 Sep 2006 12:13:43 -0700 (PDT) In-Reply-To: Original-To: "Drew Adams" User-Agent: SquirrelMail/1.4.6-7.el3.7lanl X-Priority: 3 (Normal) Importance: Normal X-PMX-Version: 4.7.1.128075 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:59386 Archived-At: > If, on the other hand, the use of delq in `cancel-timer' is unintentional > and is not needed, then perhaps delete should be used instead of delq, so > that all timers with the same parameters are cancelled at once. Others have talked about the philosophy of timers, but let me point out that this particular idea wouldn't work anyway. Evaluate this to see why: (let ((ts (list (run-with-timer 1.2 1 'ignore) (progn (sit-for 0.2) (run-with-timer 1.2 1 'ignore))))) (message "%s" ts) (prog1 (equal (car ts) (cadr ts)) (mapcar 'cancel-timer ts))) Because the precise timing of a timer (especially a repeating one) depends on when it was created and how much time has since elapsed, the internal representation of a timer cannot be merely its invocation parameters (and in fact loses the delay argument, because a timer delayed by 10s started 9s ago looks the same as one delayed by 1s started now). So "similar" timers aren't necessarily `equal', and not all timers that are `equal' were created with a call to `run-with-timer' with the same arguments. (Some may have been generated with `timer-create' directly!) In other words, we use `eq' because using `equal' doesn't work (although there are obviously other implementations that could support such a practice). Perhaps what you want is `cancel-function-timers'? Certainly for testing it's quite useful. You could also just store some "mundane" value of `timer-list' somewhere and restore it instead of specifically cancelling anything. Hope this helps, Davis -- This product is sold by volume, not by mass. If it appears too dense or too sparse, it is because mass-energy conversion has occurred during shipping.