From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: About features Date: Wed, 06 Mar 2013 18:55:14 -0500 Organization: A noiseless patient Spider Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 X-Trace: ger.gmane.org 1362621824 27374 80.91.229.3 (7 Mar 2013 02:03:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 7 Mar 2013 02:03:44 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 07 03:04:08 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UDQBj-0004IP-CX for geh-help-gnu-emacs@m.gmane.org; Thu, 07 Mar 2013 03:04:07 +0100 Original-Received: from localhost ([::1]:44488 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDQBN-0005fF-Nb for geh-help-gnu-emacs@m.gmane.org; Wed, 06 Mar 2013 21:03:45 -0500 X-Received: by 10.180.8.4 with SMTP id n4mr5708442wia.0.1362614115232; Wed, 06 Mar 2013 15:55:15 -0800 (PST) Original-Path: usenet.stanford.edu!19no14286709wij.1!news-out.google.com!g1ni50608wig.0!nntp.google.com!feeder1.cambriumusenet.nl!82.197.223.108.MISMATCH!feeder2.cambriumusenet.nl!feed.tweaknews.nl!195.62.100.242.MISMATCH!newsfeed.kamp.net!newsfeed.kamp.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!dont-email.me!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 32 Injection-Info: dont-email.me; posting-host="2be9e9f5dd9af768b8861af71b85fc28"; logging-data="30565"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19FhSDnPF6hp3wrWxZ3sIdI" User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Cancel-Lock: sha1:mXeyem0+y8gCMdSwslbdo2roPJA= Original-Xref: usenet.stanford.edu gnu.emacs.help:197121 X-Mailman-Approved-At: Wed, 06 Mar 2013 21:03:07 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:89400 Archived-At: In article , Xue Fuqiao wrote: > >> Why should we use `provide' and `require'? Is > >> `load'/`load-library'/`load-file' > >> enough? Thanks. > > > > `provide' allows you to `require' unconditionally, but the library/file > > will > > only be loaded if necessary. > > Why? Can you explain it more detailed? Why don't you just look at the source code? Simplifying, it's something like: (defun require (feature) (if (not (member feature features)) (load feature))) (defun provide (feature) (if (not (member feature features)) (push feature features))) As I said in my earlier response: require won't reload a library if it's already been loaded, and it uses the features variable to keep track of which libraries have been loaded this way. -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me ***