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

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

Re: test for presence of library


From: Pascal J. Bourguignon
Subject: Re: test for presence of library
Date: Fri, 19 Feb 2010 02:09:32 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (darwin)

Harry Putnam <address@hidden> writes:

> Can one test for the presence of a library before requiring it?
>
> I mean in the way one might test for the presence of a file in common
> shell script; if [ -f /my/file ];then
>                   blab blab
>               fi
>
> Only here we are testing for the presence of a library somewhere in
> the load path rather than a specific file location.
>
> The lisp equivalent of:
>
>  if some-lib 
>  then
>     (require some-lib)
>  fi


require does the test itself!

C-h f require RET


Now, assume that we wrote:

(when (library-exists-p 'some-lib)
   (require 'some-lib))

and that just after your emacs executed (library-exists-p 'some-lib)
and returned true, some other process would delete that some-lib.el
file.  What would happen to your (require 'some-lib)?


That is, basically, your above shell script with if [ -f /my/file ] is
just WRONG!  If you see such tests in scripts, you are allowed to think
poorly of their authors.



-- 
__Pascal Bourguignon__


reply via email to

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