From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.devel Subject: Re: [dieter@duenenhof-wilhelm.de: image-dired (tumme) database file not existing] Date: Thu, 19 Jul 2007 17:37:10 +0200 Message-ID: <87sl7kxv4p.fsf@ambire.localdomain> References: <87y7hcxz5x.fsf@ambire.localdomain> <7dbe73ed0707190803s2e4d341bxad6368085041af21@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1184859476 23121 80.91.229.12 (19 Jul 2007 15:37:56 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 19 Jul 2007 15:37:56 +0000 (UTC) Cc: dieter@duenenhof-wilhelm.de, emacs-devel@gnu.org To: "Mathias Dahl" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 19 17:37:54 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IBY4c-0004n6-59 for ged-emacs-devel@m.gmane.org; Thu, 19 Jul 2007 17:37:50 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IBY4Z-0007aU-Ew for ged-emacs-devel@m.gmane.org; Thu, 19 Jul 2007 11:37:47 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IBY4N-0007Ly-5z for emacs-devel@gnu.org; Thu, 19 Jul 2007 11:37:35 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IBY4L-0007Ix-A0 for emacs-devel@gnu.org; Thu, 19 Jul 2007 11:37:34 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IBY4L-0007Il-42 for emacs-devel@gnu.org; Thu, 19 Jul 2007 11:37:33 -0400 Original-Received: from smtp-out3.libero.it ([212.52.84.43]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IBY4K-0004Da-Lg for emacs-devel@gnu.org; Thu, 19 Jul 2007 11:37:32 -0400 Original-Received: from localhost (172.31.0.52) by smtp-out3.libero.it (7.3.120) id 4688F31B01B8D7A0 for emacs-devel@gnu.org; Thu, 19 Jul 2007 17:37:31 +0200 X-Scanned: with antispam and antivirus automated system at libero.it Original-Received: from smtp-out3.libero.it ([172.31.0.39]) by localhost (asav-out11.libero.it [192.168.32.39]) (amavisd-new, port 10024) with ESMTP id rkmHNfKBYLE5 for ; Thu, 19 Jul 2007 17:37:31 +0200 (CEST) Original-Received: from mailrelay07.libero.it (192.168.32.94) by smtp-out3.libero.it (7.3.120) id 4611FDB607FF1096 for emacs-devel@gnu.org; Thu, 19 Jul 2007 17:37:31 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAHMin0aXFSCK/2dsb2JhbAA Original-Received: from ppp-138-32.21-151.libero.it (HELO ambire.localdomain) ([151.21.32.138]) by OutRelay-b07.libero.it with ESMTP; 19 Jul 2007 17:37:30 +0200 Original-Received: from ttn by ambire.localdomain with local (Exim 4.63) (envelope-from ) id 1IBY3y-0005Z5-PA; Thu, 19 Jul 2007 17:37:10 +0200 In-Reply-To: <7dbe73ed0707190803s2e4d341bxad6368085041af21@mail.gmail.com> (Mathias Dahl's message of "Thu\, 19 Jul 2007 17\:03\:09 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) X-detected-kernel: Linux 2.4-2.6 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:75126 Archived-At: () "Mathias Dahl" () Thu, 19 Jul 2007 17:03:09 +0200 Instead of making each function make sure a db file exist, why not change code like this: (find-file image-dired-db-file) into this: (find-file (image-dired-db-file)) And inside that new defun basically do what you did in your new function. well, i considered that, too, but decided against it due to the following reasoning (somewhat muddied by the summer heat): there are two phases to the code's relationship w/ the file: 0/ ascertaining that it exists; 1/ accessing it. i think it's best to keep these separate because the cost of phase 0 should be minimized. when they are performed separately, a knowledgable programmer (such as the author of image-dired.el ;-) can further decrease the costs by avoiding phase 0 altogether in some places, by reasoning about the call graph, where the unknowledgable programmer (me) mechanistically added "safe" calls. in other words, there is some upside to the separate approach; it invites refined hacking. when the phases are performed together, no such potential exists (except in reworking the code to separate them; ie., inviting more hacking than necessary :-). of course, one could argue lots of file-exists-p calls are no big deal, but i would not be that one. (half-informed philosophical mumbling follows) what we see here is the basic tension between functional programming and the real world (external) state... change happens but is it the root or the leaves that must react? thi