Closed robertbachmann closed 3 years ago
I found success with LuaTeX's \begincsname
, which means that the check for existence is done twice, but no relaxed variant is created. I didn't find success with \lastnamedcs
.
\fontfam[lm]
%\_def \_slet #1#2{\_ea\_let \_csname#1\_ea\_endcsname \_csname#2\_endcsname}
\_def \_slet #1#2{\_ea\_let \_csname#1\_ea\_endcsname
\_ifcsname#2\_ea\_endcsname
\_begincsname#2\_endcsname
\_else
\_undefined
\_fi
}
\_public \slet ;
{
\def\foo{...}
\global\let\foo=\_undefined
\meaning\foo { and} \meaning\_undefined
% OK: undefined and undefined
}\par
\meaning\foo { and} \meaning\_undefined
% OK: undefined and undefined
{
\def\foo{...}
\global\slet{foo}{_undefined}
\meaning\foo { and} \meaning\_undefined
% OK: undefined and undefined
}\par
\meaning\foo { and} \meaning\_undefined
% OK: undefined and undefined
{
\def\foo{a}
\global\slet{bar}{foo}
\meaning\foo { and} \meaning\bar
}\par
\meaning\foo { and} \meaning\bar
% OK: undefined and macro:->a
\def\foo{...}
{
\let\foo\def
\global\slet{bar}{foo}
\meaning\foo { and} \meaning\bar
% OK: \def and \def
}\par
\meaning\foo { and} \meaning\bar
% OK: macro:->... and \def
\bye
Proof of concept fix:
This fix is incomplete, for example
\global\slet{x}{y}
would not work anymore.