[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 <reader@newsguy.com> 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__
- test for presence of library, Harry Putnam, 2010/02/18
- Re: test for presence of library,
Pascal J. Bourguignon <=
- Message not available
- Re: test for presence of library, Will Parsons, 2010/02/21
- RE: test for presence of library, Drew Adams, 2010/02/21
- Re: test for presence of library, Pascal J. Bourguignon, 2010/02/21
- Re: test for presence of library, Harry Putnam, 2010/02/25
- Message not available
- Re: test for presence of library, Pascal J. Bourguignon, 2010/02/25
- Re: test for presence of library, Harry Putnam, 2010/02/26