emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: address@hidden: image-dired (tumme) database file not existing]


From: Thien-Thi Nguyen
Subject: Re: address@hidden: image-dired (tumme) database file not existing]
Date: Thu, 19 Jul 2007 17:37:10 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)

() "Mathias Dahl" <address@hidden>
() 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]