unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Thien-Thi Nguyen <ttn@gnuvola.org>
To: "Mathias Dahl" <mathias.dahl@gmail.com>
Cc: dieter@duenenhof-wilhelm.de, emacs-devel@gnu.org
Subject: Re: [dieter@duenenhof-wilhelm.de: image-dired (tumme) database file not existing]
Date: Thu, 19 Jul 2007 17:37:10 +0200	[thread overview]
Message-ID: <87sl7kxv4p.fsf@ambire.localdomain> (raw)
In-Reply-To: <7dbe73ed0707190803s2e4d341bxad6368085041af21@mail.gmail.com> (Mathias Dahl's message of "Thu\, 19 Jul 2007 17\:03\:09 +0200")

() "Mathias Dahl" <mathias.dahl@gmail.com>
() 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	other threads:[~2007-07-19 15:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-19 12:23 [dieter@duenenhof-wilhelm.de: image-dired (tumme) database file not existing] Richard Stallman
2007-07-19 14:10 ` Thien-Thi Nguyen
2007-07-19 15:03   ` Mathias Dahl
2007-07-19 15:37     ` Thien-Thi Nguyen [this message]
2007-07-20  5:25       ` tomas
2007-07-20  6:44         ` Thien-Thi Nguyen
2007-07-20  8:10           ` tomas
2007-07-21 23:36   ` Mathias Dahl
2007-07-21 23:49     ` Thien-Thi Nguyen
2007-07-22 18:36       ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sl7kxv4p.fsf@ambire.localdomain \
    --to=ttn@gnuvola.org \
    --cc=dieter@duenenhof-wilhelm.de \
    --cc=emacs-devel@gnu.org \
    --cc=mathias.dahl@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).