From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Treatise on require Date: Sun, 08 Jan 2006 21:20:09 -0500 Message-ID: <87wthakv9j.fsf-monnier+emacs@gnu.org> References: <28049.1136694802@olgas.newt.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1136773381 4524 80.91.229.2 (9 Jan 2006 02:23:01 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 9 Jan 2006 02:23:01 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 09 03:22:59 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 1EvmgU-0002zs-Rx for ged-emacs-devel@m.gmane.org; Mon, 09 Jan 2006 03:22:59 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EvmiO-0006fv-V3 for ged-emacs-devel@m.gmane.org; Sun, 08 Jan 2006 21:24:57 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Evmfj-0004bV-P3 for emacs-devel@gnu.org; Sun, 08 Jan 2006 21:22:11 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Evmfh-0004YP-Rx for emacs-devel@gnu.org; Sun, 08 Jan 2006 21:22:10 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Evmfh-0004Xv-Ih for emacs-devel@gnu.org; Sun, 08 Jan 2006 21:22:09 -0500 Original-Received: from [209.226.175.188] (helo=tomts25-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Evmht-0008Hl-UN for emacs-devel@gnu.org; Sun, 08 Jan 2006 21:24:26 -0500 Original-Received: from alfajor ([67.71.26.73]) by tomts25-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20060109022009.PQOI25777.tomts25-srv.bellnexxia.net@alfajor>; Sun, 8 Jan 2006 21:20:09 -0500 Original-Received: by alfajor (Postfix, from userid 1000) id C1911D733B; Sun, 8 Jan 2006 21:20:09 -0500 (EST) Original-To: emacs-devel@gnu.org In-Reply-To: <28049.1136694802@olgas.newt.com> (Bill Wohler's message of "Sat, 07 Jan 2006 20:33:22 -0800") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) 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:48864 Archived-At: > Is there a treatise on loading that shows best practices in the use of > require, autoload, defvar, eval-when-compile, eval-and-compile? I think `defvar' in an outlier in your list. It's unrelated. `eval-and-compile' is only useful for self-dependencies (e.g. when a macro uses the value of a variable defined in the same file: so the variable definition needs to be evaluated both at compile time (when you use the macros) and at run time) so it's not related either. > Over time, nasty circular dependencies have reared their ugly head in > MH-E. Get rid of them by moving things around, including into new files. Sometimes merging small files into one big one makes more sense. > For example, mh-e requires just about other file That's to be expected: mh-e.el probably uses most/all of the mh-e code. > and just about every other file requires mh-e. That can't be right. > This is currently handled by putting the call to provides (in mh-e.el) > before the various calls to require (whose files require mh-e). Bad idea. > I'm sort of thinking that it might be better to replace the require > calls with something like: > (eval-when-compile > (autoload 'foo "foo") > (defvar foo)) Better not. Especially the `defvar' inside `eval-when-compile' is basically meaningless, it should be moved out. > This would placate the compiler without creating require loops. If you like to fix symptoms rather than causes, go for it. Or better yet: use `with-no-warnings'. But I'd advise you against it. Stefan