Does expanded replace the romannumeral trick for expansion?How to do scantokens inside edef without triggering “Runaway definition”Does noexpand have to be a primitive?How do I examine a token?How to vanish relax inserted by TeX itselfWhy isn't everything expandable?Expansion in numexpr…relax versus pdfstrcmpA typeout (or expandable command) that can expand once - or with variable levels of expansion?How does your mind bend expandafter to its will?The laws of expansion (chardeffoo=<number>foo)Distinguish active characters from non-active pendants with expansion-methods only?
UUID type for NEWID()
What color to choose as "danger" if the main color of my app is red
Why does SSL Labs now consider CBC suites weak?
Were any toxic metals used in the International Space Station?
Given 0s on Assignments with suspected and dismissed cheating?
When did game consoles begin including FPUs?
Word for "activity tracker" or "smart bracelet"
Using chord iii in a chord progression (major key)
Will consteval functions allow template parameters dependent on function arguments?
Will the volt, ampere, ohm or other electrical units change on May 20th, 2019?
Do people who work at research institutes consider themselves "academics"?
Should I communicate in my applications that I'm unemployed out of choice rather than because nobody will have me?
Can I say: "When was your train leaving?" if the train leaves in the future?
c++ conditional uni-directional iterator
Why can't I share a one use code with anyone else?
Will British Airways compensate if my entertainment screen was defective for an entire flight?
the correct order of manual install WP and SSL on server
The difference between きわめて and いたって
Who commanded or executed this action in Game of Thrones S8E5?
Does the wearer know what items are in which patch in the Robe of Useful items?
Single word that parallels "Recent" when discussing the near future
How does Ctrl+c and Ctrl+v work?
Could there be something like aerobatic smoke trails in the vacuum of space?
What metal is most suitable for a ladder submerged in an underground water tank?
Does expanded replace the romannumeral trick for expansion?
How to do scantokens inside edef without triggering “Runaway definition”Does noexpand have to be a primitive?How do I examine a token?How to vanish relax inserted by TeX itselfWhy isn't everything expandable?Expansion in numexpr…relax versus pdfstrcmpA typeout (or expandable command) that can expand once - or with variable levels of expansion?How does your mind bend expandafter to its will?The laws of expansion (chardeffoo=<number>foo)Distinguish active characters from non-active pendants with expansion-methods only?
TeXLive 2019 is here :D
One of its awaited features is the new expanded primitive now available in all of the main engines (only available in LuaTeX in previous years) thanks to Joseph Wright.
What we had up to now was:
Full expansion with
edefand the like;
Pros: expands the entire token list respectingprotected(any form thereof) tokens
Cons: being an assignment operation, it is not itself expandable;Partial expansion exploiting
romannumeral, which expands tokens while looking for an⟨integer⟩and a trailing⟨optional space⟩;
Pros: is expandable, allowing one1 to write some really interesting macros (including an expandable emulation of theexpandedprimitive);
Cons: only expands the “head” of the token list, stopping as soon as it finds an expandable token which does not fit into its argument specification;
expanded gives a nice mix of both, allowing us to get the full expansion of a token list while being itself expandable, apparently covering a great deal of the use-cases of both edef and romannumeral.
Of course edef still is really useful when the expansion of the tokens needs to be stored in a macro, and the produced macro can take arguments normally, which aren't features of expanded.
The romannumeral trick, however, seems to have lost much of it's usefulness with expanded. From what I understand, many situations which required romannumeral to get the full expansion of something, now can use expanded for the same effect with a proper expansion primitive.
I know that the answer to the question in the title is “no” because there are a few situations in which romannumeral is still useful. The main one, I think, are undelimited arguments; expanded requires the material to be expanded as a ⟨general text⟩ argument, while romannumeral can be put in the token and act indefinitely, until an unexpandable token is found. Another situation is, of course, when one really wants only the head of the token list expanded, then romannumeral is the tool for the job.
But both these situations seem much smaller than the entire scope of using romannumeral for expansion. Thus my question (finally) is: can the expansion trick with romannumeral be replaced mostly everywhere (as an example I can mention the LaTeX3 kernel, which heavily uses this romannumeral-powered expansion)? What other situations require romannumeral for expansion and will not work with expanded?
1In this case a very particular one :)
tex-core expansion programming texlive-2019
add a comment |
TeXLive 2019 is here :D
One of its awaited features is the new expanded primitive now available in all of the main engines (only available in LuaTeX in previous years) thanks to Joseph Wright.
What we had up to now was:
Full expansion with
edefand the like;
Pros: expands the entire token list respectingprotected(any form thereof) tokens
Cons: being an assignment operation, it is not itself expandable;Partial expansion exploiting
romannumeral, which expands tokens while looking for an⟨integer⟩and a trailing⟨optional space⟩;
Pros: is expandable, allowing one1 to write some really interesting macros (including an expandable emulation of theexpandedprimitive);
Cons: only expands the “head” of the token list, stopping as soon as it finds an expandable token which does not fit into its argument specification;
expanded gives a nice mix of both, allowing us to get the full expansion of a token list while being itself expandable, apparently covering a great deal of the use-cases of both edef and romannumeral.
Of course edef still is really useful when the expansion of the tokens needs to be stored in a macro, and the produced macro can take arguments normally, which aren't features of expanded.
The romannumeral trick, however, seems to have lost much of it's usefulness with expanded. From what I understand, many situations which required romannumeral to get the full expansion of something, now can use expanded for the same effect with a proper expansion primitive.
I know that the answer to the question in the title is “no” because there are a few situations in which romannumeral is still useful. The main one, I think, are undelimited arguments; expanded requires the material to be expanded as a ⟨general text⟩ argument, while romannumeral can be put in the token and act indefinitely, until an unexpandable token is found. Another situation is, of course, when one really wants only the head of the token list expanded, then romannumeral is the tool for the job.
But both these situations seem much smaller than the entire scope of using romannumeral for expansion. Thus my question (finally) is: can the expansion trick with romannumeral be replaced mostly everywhere (as an example I can mention the LaTeX3 kernel, which heavily uses this romannumeral-powered expansion)? What other situations require romannumeral for expansion and will not work with expanded?
1In this case a very particular one :)
tex-core expansion programming texlive-2019
add a comment |
TeXLive 2019 is here :D
One of its awaited features is the new expanded primitive now available in all of the main engines (only available in LuaTeX in previous years) thanks to Joseph Wright.
What we had up to now was:
Full expansion with
edefand the like;
Pros: expands the entire token list respectingprotected(any form thereof) tokens
Cons: being an assignment operation, it is not itself expandable;Partial expansion exploiting
romannumeral, which expands tokens while looking for an⟨integer⟩and a trailing⟨optional space⟩;
Pros: is expandable, allowing one1 to write some really interesting macros (including an expandable emulation of theexpandedprimitive);
Cons: only expands the “head” of the token list, stopping as soon as it finds an expandable token which does not fit into its argument specification;
expanded gives a nice mix of both, allowing us to get the full expansion of a token list while being itself expandable, apparently covering a great deal of the use-cases of both edef and romannumeral.
Of course edef still is really useful when the expansion of the tokens needs to be stored in a macro, and the produced macro can take arguments normally, which aren't features of expanded.
The romannumeral trick, however, seems to have lost much of it's usefulness with expanded. From what I understand, many situations which required romannumeral to get the full expansion of something, now can use expanded for the same effect with a proper expansion primitive.
I know that the answer to the question in the title is “no” because there are a few situations in which romannumeral is still useful. The main one, I think, are undelimited arguments; expanded requires the material to be expanded as a ⟨general text⟩ argument, while romannumeral can be put in the token and act indefinitely, until an unexpandable token is found. Another situation is, of course, when one really wants only the head of the token list expanded, then romannumeral is the tool for the job.
But both these situations seem much smaller than the entire scope of using romannumeral for expansion. Thus my question (finally) is: can the expansion trick with romannumeral be replaced mostly everywhere (as an example I can mention the LaTeX3 kernel, which heavily uses this romannumeral-powered expansion)? What other situations require romannumeral for expansion and will not work with expanded?
1In this case a very particular one :)
tex-core expansion programming texlive-2019
TeXLive 2019 is here :D
One of its awaited features is the new expanded primitive now available in all of the main engines (only available in LuaTeX in previous years) thanks to Joseph Wright.
What we had up to now was:
Full expansion with
edefand the like;
Pros: expands the entire token list respectingprotected(any form thereof) tokens
Cons: being an assignment operation, it is not itself expandable;Partial expansion exploiting
romannumeral, which expands tokens while looking for an⟨integer⟩and a trailing⟨optional space⟩;
Pros: is expandable, allowing one1 to write some really interesting macros (including an expandable emulation of theexpandedprimitive);
Cons: only expands the “head” of the token list, stopping as soon as it finds an expandable token which does not fit into its argument specification;
expanded gives a nice mix of both, allowing us to get the full expansion of a token list while being itself expandable, apparently covering a great deal of the use-cases of both edef and romannumeral.
Of course edef still is really useful when the expansion of the tokens needs to be stored in a macro, and the produced macro can take arguments normally, which aren't features of expanded.
The romannumeral trick, however, seems to have lost much of it's usefulness with expanded. From what I understand, many situations which required romannumeral to get the full expansion of something, now can use expanded for the same effect with a proper expansion primitive.
I know that the answer to the question in the title is “no” because there are a few situations in which romannumeral is still useful. The main one, I think, are undelimited arguments; expanded requires the material to be expanded as a ⟨general text⟩ argument, while romannumeral can be put in the token and act indefinitely, until an unexpandable token is found. Another situation is, of course, when one really wants only the head of the token list expanded, then romannumeral is the tool for the job.
But both these situations seem much smaller than the entire scope of using romannumeral for expansion. Thus my question (finally) is: can the expansion trick with romannumeral be replaced mostly everywhere (as an example I can mention the LaTeX3 kernel, which heavily uses this romannumeral-powered expansion)? What other situations require romannumeral for expansion and will not work with expanded?
1In this case a very particular one :)
tex-core expansion programming texlive-2019
tex-core expansion programming texlive-2019
asked May 3 at 22:42
Phelype OleinikPhelype Oleinik
27.4k54793
27.4k54793
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
In many case the romannumeral trick is obsolete, but there are at least two cases where it still is useful.
The first is in that as mentioned in the question it's 'open ended', whereas expanded requires an argument to be grabbed. The second is that romannumeral expansion works through tokens exactly as TeX itself does when typesetting, up to the point it finds some 'payload'. This allows us to deal with any expandable material and then 'look ahead' at the first non-expandable token. An example from l3galley:
cs_new_protected:Npn galley_par:
s__galley_par_omit
exp_after:wN __galley_par_auxi: exp:w exp_end_continue_f:w
cs_new_protected:Npn __galley_par_auxi:
peek_meaning:NTF s__galley_par_omit
__galley_par_aux:N
__galley_par_auxii:
cs_new_protected:Npn __galley_par_aux:N #1
str_if_eq:nnF #1 s__galley_par_omit
__galley_par_auxii:
#1
The romannumeral here is hidden inside exp:w, but the idea is simple. The expansion will continue until some non-expandable token is found. We then 'come back' to a look-ahead, which checks for a token that is exactly equivalent to s__galley_par_omit, a marker for consecutive par tokens. This needs the open-ended nature of romannumeral and the fact that it stops.
It's also worth noting that romannumeral ignores protected status: that shows up above, and would also be handy in implementing for example halign in macros. (This is another place we need a look-ahead.)
These aspects are quite specialised, and in most cases do not apply. The bigger barrier to shifting to expanded is that it is only now generally available: it will be many years before it is safe to assume that expanded is safe to use without a fall-back.
Oh, I completely overlooked theprotectedmacros. I think this would make a nice way to test if a macro is protected. The look ahead thing looks interesting though :)
– Phelype Oleinik
May 3 at 23:36
@Myself No, it wouldn't andexpl3already hastoken_if_protected_macro:NTF:)
– Phelype Oleinik
May 3 at 23:58
add a comment |
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',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f489063%2fdoes-expanded-replace-the-romannumeral-trick-for-expansion%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In many case the romannumeral trick is obsolete, but there are at least two cases where it still is useful.
The first is in that as mentioned in the question it's 'open ended', whereas expanded requires an argument to be grabbed. The second is that romannumeral expansion works through tokens exactly as TeX itself does when typesetting, up to the point it finds some 'payload'. This allows us to deal with any expandable material and then 'look ahead' at the first non-expandable token. An example from l3galley:
cs_new_protected:Npn galley_par:
s__galley_par_omit
exp_after:wN __galley_par_auxi: exp:w exp_end_continue_f:w
cs_new_protected:Npn __galley_par_auxi:
peek_meaning:NTF s__galley_par_omit
__galley_par_aux:N
__galley_par_auxii:
cs_new_protected:Npn __galley_par_aux:N #1
str_if_eq:nnF #1 s__galley_par_omit
__galley_par_auxii:
#1
The romannumeral here is hidden inside exp:w, but the idea is simple. The expansion will continue until some non-expandable token is found. We then 'come back' to a look-ahead, which checks for a token that is exactly equivalent to s__galley_par_omit, a marker for consecutive par tokens. This needs the open-ended nature of romannumeral and the fact that it stops.
It's also worth noting that romannumeral ignores protected status: that shows up above, and would also be handy in implementing for example halign in macros. (This is another place we need a look-ahead.)
These aspects are quite specialised, and in most cases do not apply. The bigger barrier to shifting to expanded is that it is only now generally available: it will be many years before it is safe to assume that expanded is safe to use without a fall-back.
Oh, I completely overlooked theprotectedmacros. I think this would make a nice way to test if a macro is protected. The look ahead thing looks interesting though :)
– Phelype Oleinik
May 3 at 23:36
@Myself No, it wouldn't andexpl3already hastoken_if_protected_macro:NTF:)
– Phelype Oleinik
May 3 at 23:58
add a comment |
In many case the romannumeral trick is obsolete, but there are at least two cases where it still is useful.
The first is in that as mentioned in the question it's 'open ended', whereas expanded requires an argument to be grabbed. The second is that romannumeral expansion works through tokens exactly as TeX itself does when typesetting, up to the point it finds some 'payload'. This allows us to deal with any expandable material and then 'look ahead' at the first non-expandable token. An example from l3galley:
cs_new_protected:Npn galley_par:
s__galley_par_omit
exp_after:wN __galley_par_auxi: exp:w exp_end_continue_f:w
cs_new_protected:Npn __galley_par_auxi:
peek_meaning:NTF s__galley_par_omit
__galley_par_aux:N
__galley_par_auxii:
cs_new_protected:Npn __galley_par_aux:N #1
str_if_eq:nnF #1 s__galley_par_omit
__galley_par_auxii:
#1
The romannumeral here is hidden inside exp:w, but the idea is simple. The expansion will continue until some non-expandable token is found. We then 'come back' to a look-ahead, which checks for a token that is exactly equivalent to s__galley_par_omit, a marker for consecutive par tokens. This needs the open-ended nature of romannumeral and the fact that it stops.
It's also worth noting that romannumeral ignores protected status: that shows up above, and would also be handy in implementing for example halign in macros. (This is another place we need a look-ahead.)
These aspects are quite specialised, and in most cases do not apply. The bigger barrier to shifting to expanded is that it is only now generally available: it will be many years before it is safe to assume that expanded is safe to use without a fall-back.
Oh, I completely overlooked theprotectedmacros. I think this would make a nice way to test if a macro is protected. The look ahead thing looks interesting though :)
– Phelype Oleinik
May 3 at 23:36
@Myself No, it wouldn't andexpl3already hastoken_if_protected_macro:NTF:)
– Phelype Oleinik
May 3 at 23:58
add a comment |
In many case the romannumeral trick is obsolete, but there are at least two cases where it still is useful.
The first is in that as mentioned in the question it's 'open ended', whereas expanded requires an argument to be grabbed. The second is that romannumeral expansion works through tokens exactly as TeX itself does when typesetting, up to the point it finds some 'payload'. This allows us to deal with any expandable material and then 'look ahead' at the first non-expandable token. An example from l3galley:
cs_new_protected:Npn galley_par:
s__galley_par_omit
exp_after:wN __galley_par_auxi: exp:w exp_end_continue_f:w
cs_new_protected:Npn __galley_par_auxi:
peek_meaning:NTF s__galley_par_omit
__galley_par_aux:N
__galley_par_auxii:
cs_new_protected:Npn __galley_par_aux:N #1
str_if_eq:nnF #1 s__galley_par_omit
__galley_par_auxii:
#1
The romannumeral here is hidden inside exp:w, but the idea is simple. The expansion will continue until some non-expandable token is found. We then 'come back' to a look-ahead, which checks for a token that is exactly equivalent to s__galley_par_omit, a marker for consecutive par tokens. This needs the open-ended nature of romannumeral and the fact that it stops.
It's also worth noting that romannumeral ignores protected status: that shows up above, and would also be handy in implementing for example halign in macros. (This is another place we need a look-ahead.)
These aspects are quite specialised, and in most cases do not apply. The bigger barrier to shifting to expanded is that it is only now generally available: it will be many years before it is safe to assume that expanded is safe to use without a fall-back.
In many case the romannumeral trick is obsolete, but there are at least two cases where it still is useful.
The first is in that as mentioned in the question it's 'open ended', whereas expanded requires an argument to be grabbed. The second is that romannumeral expansion works through tokens exactly as TeX itself does when typesetting, up to the point it finds some 'payload'. This allows us to deal with any expandable material and then 'look ahead' at the first non-expandable token. An example from l3galley:
cs_new_protected:Npn galley_par:
s__galley_par_omit
exp_after:wN __galley_par_auxi: exp:w exp_end_continue_f:w
cs_new_protected:Npn __galley_par_auxi:
peek_meaning:NTF s__galley_par_omit
__galley_par_aux:N
__galley_par_auxii:
cs_new_protected:Npn __galley_par_aux:N #1
str_if_eq:nnF #1 s__galley_par_omit
__galley_par_auxii:
#1
The romannumeral here is hidden inside exp:w, but the idea is simple. The expansion will continue until some non-expandable token is found. We then 'come back' to a look-ahead, which checks for a token that is exactly equivalent to s__galley_par_omit, a marker for consecutive par tokens. This needs the open-ended nature of romannumeral and the fact that it stops.
It's also worth noting that romannumeral ignores protected status: that shows up above, and would also be handy in implementing for example halign in macros. (This is another place we need a look-ahead.)
These aspects are quite specialised, and in most cases do not apply. The bigger barrier to shifting to expanded is that it is only now generally available: it will be many years before it is safe to assume that expanded is safe to use without a fall-back.
edited May 3 at 23:41
Henri Menke
79.1k9172285
79.1k9172285
answered May 3 at 23:10
Joseph Wright♦Joseph Wright
207k23568897
207k23568897
Oh, I completely overlooked theprotectedmacros. I think this would make a nice way to test if a macro is protected. The look ahead thing looks interesting though :)
– Phelype Oleinik
May 3 at 23:36
@Myself No, it wouldn't andexpl3already hastoken_if_protected_macro:NTF:)
– Phelype Oleinik
May 3 at 23:58
add a comment |
Oh, I completely overlooked theprotectedmacros. I think this would make a nice way to test if a macro is protected. The look ahead thing looks interesting though :)
– Phelype Oleinik
May 3 at 23:36
@Myself No, it wouldn't andexpl3already hastoken_if_protected_macro:NTF:)
– Phelype Oleinik
May 3 at 23:58
Oh, I completely overlooked the
protected macros. I think this would make a nice way to test if a macro is protected. The look ahead thing looks interesting though :)– Phelype Oleinik
May 3 at 23:36
Oh, I completely overlooked the
protected macros. I think this would make a nice way to test if a macro is protected. The look ahead thing looks interesting though :)– Phelype Oleinik
May 3 at 23:36
@Myself No, it wouldn't and
expl3 already has token_if_protected_macro:NTF :)– Phelype Oleinik
May 3 at 23:58
@Myself No, it wouldn't and
expl3 already has token_if_protected_macro:NTF :)– Phelype Oleinik
May 3 at 23:58
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f489063%2fdoes-expanded-replace-the-romannumeral-trick-for-expansion%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown