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

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

Re: (require 'filename) doesn't find the file


From: tomas
Subject: Re: (require 'filename) doesn't find the file
Date: Fri, 10 Mar 2017 10:55:10 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Mar 10, 2017 at 10:38:29AM +0100, hector wrote:
> >From the Emacs lisp manual:
>      If loading the file succeeds but does not provide FEATURE,
>      `require' signals an error, `Required feature FEATURE was not
>      provided'.
> 
> This part is a bit obscure. So, it does what I want (loading the file)
> but signals an error? I don't get it.
> 
> So is it bad practice to use the file name as a feature like
> "(require 'filename)"?

No. That means, that somewhere, in the path following the (require ...),
there must be a corresponding (provide ...) *unless* something went
wrong.

Typically, the last line of "filename.el" just says (provide 'filename),
but this is just one (the most common) way of doing things.

Think like "filename.el" saying "yep, all went well, now you have
feature 'filename".

As to why this makes sense... (a) other code can ask "do we have this
feature?" (and possibly offer the user alternatives, or an apology,
or hints, or whatever) -- and (b) caching: require itself just skips
loading the file when we've got the feature. No need to load the
file one thousand times when there are thousand packages out there
depending on it.

Regards
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAljCd/4ACgkQBcgs9XrR2kY6wgCeOOu+nJAcKVprRHpBIYVr8wZz
XegAn3ZAqbHpFy4kj4Fq2xqU9OvxqdJS
=wXIQ
-----END PGP SIGNATURE-----



reply via email to

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