all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Stephen J. Turnbull" <stephen@xemacs.org>
To: William Xu <william.xwl@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Is (provide 'foo) at the start good or bad?
Date: Fri, 12 Jun 2009 19:26:24 +0900	[thread overview]
Message-ID: <87ljnxwxwv.fsf@uwakimon.sk.tsukuba.ac.jp> (raw)
In-Reply-To: <21glski6hwpf.fsf@gmail.com>

William Xu writes:

 > That makes sense.  But looks like doesn't work very well? I tried the
 > following: 

Of course that doesn't work.  You've got a dependency loop.  In this
particular case you can break it by using "just-in-time" requires:

a.el:
(provide 'a)
(defun a-hi ())
(require 'b)
(b-hi)

b.el:
(provide 'b)
(defun b-hi ())
(require 'a)
(a-hi)

but that won't always work.  However, this:

a.el:
(require 'b)
(provide 'a)

b.el:
(require 'a)
(provide 'b)

is already an infloop.

Bottom line: In mutually recursive requires, provide at the top gives
you rope.  You can knit a hammock and enjoy life, or knot a noose and
die.  Your choice.  Provide at the bottom is an obtuse way to find out
how much memory you have.  No choice.

On the other hand you do have the original problem that
eval-after-load will not necessarily work right.  This is basically
the same issue, though, and probably needs to be fixed by refactoring
eventually.  Using a mode-activation hook is one such refactoring,
although it doesn't work in this case.

 > Unfortunately, ffap has no such hook available, and it is not a mode.
 > add-to-list itself recommends eval-after-load at some point somehow:

(eval-after-load
  ;; eventually fails silently if the list-variable was never defined
  ;; probably not what you want
  (when (boundp 'list-variable)
    (add-to-list 'list-variable element-to-add)))

or

(eval-after-load
  ;; eventually fails loudly if the list-variable was never defined
  ;; probably what you want
  (unless load-file-name
    (add-to-list 'list-variable element-to-add)))

might work, but I forget the original context.

Of course Alan is correct, there is no one right way, and you might
consider the "cures" above worse than the "disease".





  parent reply	other threads:[~2009-06-12 10:26 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-11 12:56 Is (provide 'foo) at the start good or bad? William Xu
2009-06-11 17:01 ` Leo
2009-06-12  4:09   ` Stephen J. Turnbull
2009-06-12  5:01     ` William Xu
2009-06-12 10:02       ` Thien-Thi Nguyen
2009-06-12 10:26       ` Stephen J. Turnbull [this message]
2009-06-12 15:15         ` William Xu
2009-06-12  8:36     ` Alan Mackenzie
2009-06-12 10:10       ` Stephen J. Turnbull
2009-06-12 23:00     ` Davis Herring
2009-06-13 12:19       ` Stephen J. Turnbull
2009-06-14 19:30         ` Davis Herring
2009-06-15  3:04           ` Stephen J. Turnbull
2009-06-15 18:20             ` Davis Herring
2009-06-16  3:47               ` Stephen J. Turnbull
2009-06-12 21:16 ` Stefan Monnier

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

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

  git send-email \
    --in-reply-to=87ljnxwxwv.fsf@uwakimon.sk.tsukuba.ac.jp \
    --to=stephen@xemacs.org \
    --cc=emacs-devel@gnu.org \
    --cc=william.xwl@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.