\foo is accesible within the definition of \baz after \endgroup, but is otherwise `hidden' (in particular, it does not clash with \def\foo{Oops} defined after \endgroup).Code: Select all
\begingroup
\def\foo{bar}
% \xdef\baz{\foo} % OK
% \gdef\baz{\def\foo{bar}\foo}%OK
\gdef\baz{\foo} % not OK
\endgroup
\begin{document}
\baz
%\def\foo{Oops}
\end{document}\begingroup ... \endgroup altogether and replace \def\foo by \gdef\SCOPENAMEfoo and use this in the definition of \baz. I'm hoping there is a better/neater suggestion. How are packages written in this respect?