I was in correspondence with the author of a LaTeX package in which I volunteered code similar to the following (I have anonymised it so that it is not obvious what package):
\makeatletter
\newcommand{\savemacrostatewithname}[1]{%
\expandafter\let%
\csname saved@macro@state@named@#1\endcsname%
\package@internal@macro%
}
\newcommand{\restoremacrostatewithname}[1]{%
\ifcsname saved@macro@state@named@#1\endcsname%
\else%
\errmessage{Saved macro state named "#1" doesn't exist}%
\fi%
\expandafter\let%
\expandafter\package@internal@macro%
\csname saved@macro@state@named@#1\endcsname%
}
\makeatother
In their reply, one thing they said was that instead of writing #1
in your macros, you should write \detokenize{#1}
, as it is safer. Why is it safer? What might go wrong if I don't?
#1
will always be replaced with a string of ASCII characters, there's no difference.~
or_
with theunderscore
package loaded :-)underscore
that creates more problems than it solves.