Why is it convention to have `(provide )` at the bottom of the file?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I've been looking through some elisp libraries and most calls to provide
happen at the end of the file. In clojure the ns
is quite similar to provide
.
I've noticed that putting provide
at the top of the file makes no difference. Is there a reason for putting it at the end vs at the top?
provide
New contributor
add a comment |Â
up vote
1
down vote
favorite
I've been looking through some elisp libraries and most calls to provide
happen at the end of the file. In clojure the ns
is quite similar to provide
.
I've noticed that putting provide
at the top of the file makes no difference. Is there a reason for putting it at the end vs at the top?
provide
New contributor
2
Possible duplicate of What does (require 'package) mean for emacs and how does it differ from load-file?
â phils
1 hour ago
1
or emacs.stackexchange.com/q/8288 or emacs.stackexchange.com/q/18638
â phils
1 hour ago
i'm talking about 'provide, not 'require
â zcaudate
1 hour ago
@zcaudate tl;dr it's part of how(elisp) Named Features
are implemented.
â Basil
1 hour ago
1
Ah, so based on your edit you are not asking why libraries contain(provide <package>)
, but why they contain it at the bottom rather than at the top?
â phils
1 hour ago
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I've been looking through some elisp libraries and most calls to provide
happen at the end of the file. In clojure the ns
is quite similar to provide
.
I've noticed that putting provide
at the top of the file makes no difference. Is there a reason for putting it at the end vs at the top?
provide
New contributor
I've been looking through some elisp libraries and most calls to provide
happen at the end of the file. In clojure the ns
is quite similar to provide
.
I've noticed that putting provide
at the top of the file makes no difference. Is there a reason for putting it at the end vs at the top?
provide
provide
New contributor
New contributor
edited 14 mins ago
Drew
45.1k460101
45.1k460101
New contributor
asked 2 hours ago
zcaudate
1837
1837
New contributor
New contributor
2
Possible duplicate of What does (require 'package) mean for emacs and how does it differ from load-file?
â phils
1 hour ago
1
or emacs.stackexchange.com/q/8288 or emacs.stackexchange.com/q/18638
â phils
1 hour ago
i'm talking about 'provide, not 'require
â zcaudate
1 hour ago
@zcaudate tl;dr it's part of how(elisp) Named Features
are implemented.
â Basil
1 hour ago
1
Ah, so based on your edit you are not asking why libraries contain(provide <package>)
, but why they contain it at the bottom rather than at the top?
â phils
1 hour ago
add a comment |Â
2
Possible duplicate of What does (require 'package) mean for emacs and how does it differ from load-file?
â phils
1 hour ago
1
or emacs.stackexchange.com/q/8288 or emacs.stackexchange.com/q/18638
â phils
1 hour ago
i'm talking about 'provide, not 'require
â zcaudate
1 hour ago
@zcaudate tl;dr it's part of how(elisp) Named Features
are implemented.
â Basil
1 hour ago
1
Ah, so based on your edit you are not asking why libraries contain(provide <package>)
, but why they contain it at the bottom rather than at the top?
â phils
1 hour ago
2
2
Possible duplicate of What does (require 'package) mean for emacs and how does it differ from load-file?
â phils
1 hour ago
Possible duplicate of What does (require 'package) mean for emacs and how does it differ from load-file?
â phils
1 hour ago
1
1
or emacs.stackexchange.com/q/8288 or emacs.stackexchange.com/q/18638
â phils
1 hour ago
or emacs.stackexchange.com/q/8288 or emacs.stackexchange.com/q/18638
â phils
1 hour ago
i'm talking about 'provide, not 'require
â zcaudate
1 hour ago
i'm talking about 'provide, not 'require
â zcaudate
1 hour ago
@zcaudate tl;dr it's part of how
(elisp) Named Features
are implemented.â Basil
1 hour ago
@zcaudate tl;dr it's part of how
(elisp) Named Features
are implemented.â Basil
1 hour ago
1
1
Ah, so based on your edit you are not asking why libraries contain
(provide <package>)
, but why they contain it at the bottom rather than at the top?â phils
1 hour ago
Ah, so based on your edit you are not asking why libraries contain
(provide <package>)
, but why they contain it at the bottom rather than at the top?â phils
1 hour ago
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
The reason for putting the provide
at the end rather than the beginning is the same as the reason for including the comment ;;; <library.el> ends here
at the end of the file:
Because if it's not there, then you don't have the complete file.
The comment is the human-readable version of that, and (provide 'FEATURE)
is the machine-readable version.
Imagine if you had a truncated copy of foo.el
with (provide 'foo)
at the top, and loading it caused errors -- but due to the provide
Emacs believed it was now fully-loaded, and so subsequent (require 'foo)
did nothing to fix the problem in that session, even after you installed a corrected copy of the file.
1
FWIW, the purpose of the "ends here" heading is documented under(elisp) Library Headers
.
â Basil
1 hour ago
add a comment |Â
up vote
1
down vote
Because it's in the coding conventions, would be one answer. :)
The provide
/require
/features
design is quite simple. When a package requires a feature it is loaded, but only if it isn't already loaded. That is determined by checking the list of features found in features
.
Packages only add their features only once they have finished loading, i.e. only once their features become available to use. So, they do it last.
The value of the variable features
stores the list. Mine currently has ~300 symbols in it.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
The reason for putting the provide
at the end rather than the beginning is the same as the reason for including the comment ;;; <library.el> ends here
at the end of the file:
Because if it's not there, then you don't have the complete file.
The comment is the human-readable version of that, and (provide 'FEATURE)
is the machine-readable version.
Imagine if you had a truncated copy of foo.el
with (provide 'foo)
at the top, and loading it caused errors -- but due to the provide
Emacs believed it was now fully-loaded, and so subsequent (require 'foo)
did nothing to fix the problem in that session, even after you installed a corrected copy of the file.
1
FWIW, the purpose of the "ends here" heading is documented under(elisp) Library Headers
.
â Basil
1 hour ago
add a comment |Â
up vote
2
down vote
The reason for putting the provide
at the end rather than the beginning is the same as the reason for including the comment ;;; <library.el> ends here
at the end of the file:
Because if it's not there, then you don't have the complete file.
The comment is the human-readable version of that, and (provide 'FEATURE)
is the machine-readable version.
Imagine if you had a truncated copy of foo.el
with (provide 'foo)
at the top, and loading it caused errors -- but due to the provide
Emacs believed it was now fully-loaded, and so subsequent (require 'foo)
did nothing to fix the problem in that session, even after you installed a corrected copy of the file.
1
FWIW, the purpose of the "ends here" heading is documented under(elisp) Library Headers
.
â Basil
1 hour ago
add a comment |Â
up vote
2
down vote
up vote
2
down vote
The reason for putting the provide
at the end rather than the beginning is the same as the reason for including the comment ;;; <library.el> ends here
at the end of the file:
Because if it's not there, then you don't have the complete file.
The comment is the human-readable version of that, and (provide 'FEATURE)
is the machine-readable version.
Imagine if you had a truncated copy of foo.el
with (provide 'foo)
at the top, and loading it caused errors -- but due to the provide
Emacs believed it was now fully-loaded, and so subsequent (require 'foo)
did nothing to fix the problem in that session, even after you installed a corrected copy of the file.
The reason for putting the provide
at the end rather than the beginning is the same as the reason for including the comment ;;; <library.el> ends here
at the end of the file:
Because if it's not there, then you don't have the complete file.
The comment is the human-readable version of that, and (provide 'FEATURE)
is the machine-readable version.
Imagine if you had a truncated copy of foo.el
with (provide 'foo)
at the top, and loading it caused errors -- but due to the provide
Emacs believed it was now fully-loaded, and so subsequent (require 'foo)
did nothing to fix the problem in that session, even after you installed a corrected copy of the file.
answered 1 hour ago
phils
24k23261
24k23261
1
FWIW, the purpose of the "ends here" heading is documented under(elisp) Library Headers
.
â Basil
1 hour ago
add a comment |Â
1
FWIW, the purpose of the "ends here" heading is documented under(elisp) Library Headers
.
â Basil
1 hour ago
1
1
FWIW, the purpose of the "ends here" heading is documented under
(elisp) Library Headers
.â Basil
1 hour ago
FWIW, the purpose of the "ends here" heading is documented under
(elisp) Library Headers
.â Basil
1 hour ago
add a comment |Â
up vote
1
down vote
Because it's in the coding conventions, would be one answer. :)
The provide
/require
/features
design is quite simple. When a package requires a feature it is loaded, but only if it isn't already loaded. That is determined by checking the list of features found in features
.
Packages only add their features only once they have finished loading, i.e. only once their features become available to use. So, they do it last.
The value of the variable features
stores the list. Mine currently has ~300 symbols in it.
add a comment |Â
up vote
1
down vote
Because it's in the coding conventions, would be one answer. :)
The provide
/require
/features
design is quite simple. When a package requires a feature it is loaded, but only if it isn't already loaded. That is determined by checking the list of features found in features
.
Packages only add their features only once they have finished loading, i.e. only once their features become available to use. So, they do it last.
The value of the variable features
stores the list. Mine currently has ~300 symbols in it.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Because it's in the coding conventions, would be one answer. :)
The provide
/require
/features
design is quite simple. When a package requires a feature it is loaded, but only if it isn't already loaded. That is determined by checking the list of features found in features
.
Packages only add their features only once they have finished loading, i.e. only once their features become available to use. So, they do it last.
The value of the variable features
stores the list. Mine currently has ~300 symbols in it.
Because it's in the coding conventions, would be one answer. :)
The provide
/require
/features
design is quite simple. When a package requires a feature it is loaded, but only if it isn't already loaded. That is determined by checking the list of features found in features
.
Packages only add their features only once they have finished loading, i.e. only once their features become available to use. So, they do it last.
The value of the variable features
stores the list. Mine currently has ~300 symbols in it.
answered 1 hour ago
Ben Hyde
38629
38629
add a comment |Â
add a comment |Â
zcaudate is a new contributor. Be nice, and check out our Code of Conduct.
zcaudate is a new contributor. Be nice, and check out our Code of Conduct.
zcaudate is a new contributor. Be nice, and check out our Code of Conduct.
zcaudate is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2femacs.stackexchange.com%2fquestions%2f44982%2fwhy-is-it-convention-to-have-provide-package-at-the-bottom-of-the-file%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2
Possible duplicate of What does (require 'package) mean for emacs and how does it differ from load-file?
â phils
1 hour ago
1
or emacs.stackexchange.com/q/8288 or emacs.stackexchange.com/q/18638
â phils
1 hour ago
i'm talking about 'provide, not 'require
â zcaudate
1 hour ago
@zcaudate tl;dr it's part of how
(elisp) Named Features
are implemented.â Basil
1 hour ago
1
Ah, so based on your edit you are not asking why libraries contain
(provide <package>)
, but why they contain it at the bottom rather than at the top?â phils
1 hour ago