Recently I discovered a piece of code (from ucharclasses
) using three expansion-related macros \noexpand
, \unexpanded
and \expandafter
:
\def\do#1{\noexpand\setTransitionsFor{#1}{####1}{####2}}
\def\doclass#1{
\begingroup\edef\x{\endgroup
\noexpand\newcommand
\unexpanded\expandafter{\csname setTransitionsFor#1\endcsname}[2]%
{\csname #1Classes\endcsname}}\x}
\ClassGroups
I can find some references about these macros, but I still don't understand what they are doing exactly. I'd like to know why they are necessary in the above piece of code, and why would we ever need four sharps as in ####1
and ####2
.
\expandafter
: TUGBoat 9(1):57-61, 1988.\expandafter
knows about\csname
and\endcsname
. That's a case explicitly listed. But in this piece of code there'sunexpanded
before\expandafter
that still looks confusing.\unexpanded
is discussed in this thread.