What is the difference between unexpanded and protected?

Clash Royale CLAN TAG#URR8PPP
up vote
5
down vote
favorite
From the õ-TeX manual:
- Protected macros (defined with the
protectedprefix) are not expanded when building an expanded token list (foredef,xdef,message,errmessage,special,mark,marksor when writing the token list forwriteto a file) or when looking ahead in an alignment fornoalignoromit.
- When building an expanded token list, the tokens resulting from the expansion of
unexpandedare not expanded further (this is the same behaviour as is exhibited by the tokens resulting from the expansion oftheâ¨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
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.
add a comment |Â
up vote
5
down vote
favorite
From the õ-TeX manual:
- Protected macros (defined with the
protectedprefix) are not expanded when building an expanded token list (foredef,xdef,message,errmessage,special,mark,marksor when writing the token list forwriteto a file) or when looking ahead in an alignment fornoalignoromit.
- When building an expanded token list, the tokens resulting from the expansion of
unexpandedare not expanded further (this is the same behaviour as is exhibited by the tokens resulting from the expansion oftheâ¨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
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.
unexpandeddefis only used by ConTeXt, which has different namings.
â egreg
50 mins ago
add a comment |Â
up vote
5
down vote
favorite
up vote
5
down vote
favorite
From the õ-TeX manual:
- Protected macros (defined with the
protectedprefix) are not expanded when building an expanded token list (foredef,xdef,message,errmessage,special,mark,marksor when writing the token list forwriteto a file) or when looking ahead in an alignment fornoalignoromit.
- When building an expanded token list, the tokens resulting from the expansion of
unexpandedare not expanded further (this is the same behaviour as is exhibited by the tokens resulting from the expansion oftheâ¨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
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
protectedprefix) are not expanded when building an expanded token list (foredef,xdef,message,errmessage,special,mark,marksor when writing the token list forwriteto a file) or when looking ahead in an alignment fornoalignoromit.
- When building an expanded token list, the tokens resulting from the expansion of
unexpandedare not expanded further (this is the same behaviour as is exhibited by the tokens resulting from the expansion oftheâ¨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
expansion e-tex protected-macro
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.
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.
unexpandeddefis only used by ConTeXt, which has different namings.
â egreg
50 mins ago
add a comment |Â
unexpandeddefis 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
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
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.
answered 56 mins ago
David Carlisle
471k3811001829
471k3811001829
add a comment |Â
add a comment |Â
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.
G. S. 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%2ftex.stackexchange.com%2fquestions%2f455101%2fwhat-is-the-difference-between-unexpanded-and-protected%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

unexpandeddefis only used by ConTeXt, which has different namings.â egreg
50 mins ago