help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: About features


From: Barry Margolin
Subject: Re: About features
Date: Wed, 06 Mar 2013 18:55:14 -0500
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

In article <mailman.21593.1362608491.855.help-gnu-emacs@gnu.org>,
 Xue Fuqiao <xfq.free@gmail.com> 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 ***


reply via email to

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