What is the difference between unexpanded and protected?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
5
down vote

favorite












From the ε-TeX manual:




  • Protected macros (defined with the protected prefix) are not expanded when building an expanded token list (for edef, xdef, message, errmessage, special, mark, marks or when writing the token list for write to a file) or when looking ahead in an alignment for noalign or omit.

  • When building an expanded token list, the tokens resulting from the expansion of unexpanded are not expanded further (this is the same behaviour as is exhibited by the tokens resulting from the expansion of the⟨token variable⟩ in both TeX and ε-TeX).



However, in practice I've seen the two used in seemingly the exact same situations, although unexpandeddef... seems more common. Is there any notable difference between the two that I should be aware of?










share|improve this question









New contributor




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



















  • unexpandeddef is only used by ConTeXt, which has different namings.
    – egreg
    50 mins ago














up vote
5
down vote

favorite












From the ε-TeX manual:




  • Protected macros (defined with the protected prefix) are not expanded when building an expanded token list (for edef, xdef, message, errmessage, special, mark, marks or when writing the token list for write to a file) or when looking ahead in an alignment for noalign or omit.

  • When building an expanded token list, the tokens resulting from the expansion of unexpanded are not expanded further (this is the same behaviour as is exhibited by the tokens resulting from the expansion of the⟨token variable⟩ in both TeX and ε-TeX).



However, in practice I've seen the two used in seemingly the exact same situations, although unexpandeddef... seems more common. Is there any notable difference between the two that I should be aware of?










share|improve this question









New contributor




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



















  • unexpandeddef is only used by ConTeXt, which has different namings.
    – egreg
    50 mins ago












up vote
5
down vote

favorite









up vote
5
down vote

favorite











From the ε-TeX manual:




  • Protected macros (defined with the protected prefix) are not expanded when building an expanded token list (for edef, xdef, message, errmessage, special, mark, marks or when writing the token list for write to a file) or when looking ahead in an alignment for noalign or omit.

  • When building an expanded token list, the tokens resulting from the expansion of unexpanded are not expanded further (this is the same behaviour as is exhibited by the tokens resulting from the expansion of the⟨token variable⟩ in both TeX and ε-TeX).



However, in practice I've seen the two used in seemingly the exact same situations, although unexpandeddef... seems more common. Is there any notable difference between the two that I should be aware of?










share|improve this question









New contributor




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











From the ε-TeX manual:




  • Protected macros (defined with the protected prefix) are not expanded when building an expanded token list (for edef, xdef, message, errmessage, special, mark, marks or when writing the token list for write to a file) or when looking ahead in an alignment for noalign or omit.

  • When building an expanded token list, the tokens resulting from the expansion of unexpanded are not expanded further (this is the same behaviour as is exhibited by the tokens resulting from the expansion of the⟨token variable⟩ in both TeX and ε-TeX).



However, in practice I've seen the two used in seemingly the exact same situations, although unexpandeddef... seems more common. Is there any notable difference between the two that I should be aware of?







expansion e-tex protected-macro






share|improve this question









New contributor




G. S. 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




G. S. 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 7 hours ago





















New contributor




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









asked 7 hours ago









G. S.

384




384




New contributor




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





New contributor





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






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











  • unexpandeddef is only used by ConTeXt, which has different namings.
    – egreg
    50 mins ago
















  • unexpandeddef is only used by ConTeXt, which has different namings.
    – egreg
    50 mins ago















unexpandeddef is only used by ConTeXt, which has different namings.
– egreg
50 mins ago




unexpandeddef is only used by ConTeXt, which has different namings.
– egreg
50 mins ago










1 Answer
1






active

oldest

votes

















up vote
3
down vote













They are not really comparable:



protected is a modifier of def and makes the resulting token have an internal flag set so that its expansion is suppressed in certain contexts. So it is a property of the command.



unexpanded is used to prevent the expansion of a token list so it is a property of the context not of the commands that are in it.



Of course there is some overlap, if you are writing to a file and need to prevent expansion then you could (as in classic latex) declare that fragile commands will fail and so arrange that all definitions are made with protect so there are less fragile commands. Or you could use unexpanded and prevent all expansion whether or not the commands are made with protect, this would also stop any user defined commands expanding to their replacements which may or may not be what you want, depending on circumstances.






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "85"
    ;
    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
    );



    );






    G. S. 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%2ftex.stackexchange.com%2fquestions%2f455101%2fwhat-is-the-difference-between-unexpanded-and-protected%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    3
    down vote













    They are not really comparable:



    protected is a modifier of def and makes the resulting token have an internal flag set so that its expansion is suppressed in certain contexts. So it is a property of the command.



    unexpanded is used to prevent the expansion of a token list so it is a property of the context not of the commands that are in it.



    Of course there is some overlap, if you are writing to a file and need to prevent expansion then you could (as in classic latex) declare that fragile commands will fail and so arrange that all definitions are made with protect so there are less fragile commands. Or you could use unexpanded and prevent all expansion whether or not the commands are made with protect, this would also stop any user defined commands expanding to their replacements which may or may not be what you want, depending on circumstances.






    share|improve this answer
























      up vote
      3
      down vote













      They are not really comparable:



      protected is a modifier of def and makes the resulting token have an internal flag set so that its expansion is suppressed in certain contexts. So it is a property of the command.



      unexpanded is used to prevent the expansion of a token list so it is a property of the context not of the commands that are in it.



      Of course there is some overlap, if you are writing to a file and need to prevent expansion then you could (as in classic latex) declare that fragile commands will fail and so arrange that all definitions are made with protect so there are less fragile commands. Or you could use unexpanded and prevent all expansion whether or not the commands are made with protect, this would also stop any user defined commands expanding to their replacements which may or may not be what you want, depending on circumstances.






      share|improve this answer






















        up vote
        3
        down vote










        up vote
        3
        down vote









        They are not really comparable:



        protected is a modifier of def and makes the resulting token have an internal flag set so that its expansion is suppressed in certain contexts. So it is a property of the command.



        unexpanded is used to prevent the expansion of a token list so it is a property of the context not of the commands that are in it.



        Of course there is some overlap, if you are writing to a file and need to prevent expansion then you could (as in classic latex) declare that fragile commands will fail and so arrange that all definitions are made with protect so there are less fragile commands. Or you could use unexpanded and prevent all expansion whether or not the commands are made with protect, this would also stop any user defined commands expanding to their replacements which may or may not be what you want, depending on circumstances.






        share|improve this answer












        They are not really comparable:



        protected is a modifier of def and makes the resulting token have an internal flag set so that its expansion is suppressed in certain contexts. So it is a property of the command.



        unexpanded is used to prevent the expansion of a token list so it is a property of the context not of the commands that are in it.



        Of course there is some overlap, if you are writing to a file and need to prevent expansion then you could (as in classic latex) declare that fragile commands will fail and so arrange that all definitions are made with protect so there are less fragile commands. Or you could use unexpanded and prevent all expansion whether or not the commands are made with protect, this would also stop any user defined commands expanding to their replacements which may or may not be what you want, depending on circumstances.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 56 mins ago









        David Carlisle

        471k3811001829




        471k3811001829




















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









             

            draft saved


            draft discarded


















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












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











            G. S. 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%2ftex.stackexchange.com%2fquestions%2f455101%2fwhat-is-the-difference-between-unexpanded-and-protected%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            White Anglo-Saxon Protestant

            Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

            One-line joke