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
\edef
and the like;
Pros: expands the entire token list respecting\protected
(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 the\expanded
primitive);
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 :)