Why is it convention to have `(provide )` at the bottom of the file?

The name of the pictureThe name of the pictureThe name of the pictureClash 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?










share|improve this question









New contributor




zcaudate is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 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














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?










share|improve this question









New contributor




zcaudate is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 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












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?










share|improve this question









New contributor




zcaudate is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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






share|improve this question









New contributor




zcaudate is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




zcaudate is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 14 mins ago









Drew

45.1k460101




45.1k460101






New contributor




zcaudate is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 hours ago









zcaudate

1837




1837




New contributor




zcaudate is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





zcaudate is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






zcaudate is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 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




    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










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.






share|improve this answer
















  • 1




    FWIW, the purpose of the "ends here" heading is documented under (elisp) Library Headers.
    – Basil
    1 hour ago

















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.






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "583"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    zcaudate is a new contributor. Be nice, and check out our Code of Conduct.









     

    draft saved


    draft discarded


















    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






























    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.






    share|improve this answer
















    • 1




      FWIW, the purpose of the "ends here" heading is documented under (elisp) Library Headers.
      – Basil
      1 hour ago














    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.






    share|improve this answer
















    • 1




      FWIW, the purpose of the "ends here" heading is documented under (elisp) Library Headers.
      – Basil
      1 hour ago












    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.






    share|improve this answer












    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.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    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












    • 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










    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.






    share|improve this answer
























      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.






      share|improve this answer






















        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.






        share|improve this answer












        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 1 hour ago









        Ben Hyde

        38629




        38629




















            zcaudate is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            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.













             


            draft saved


            draft discarded














            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













































































            Comments

            Popular posts from this blog

            Long meetings (6-7 hours a day): Being “babysat” by supervisor

            What does second last employer means? [closed]

            One-line joke