[texhax] defin'd? (was: Trying to find...)

Uwe Lueck uwe.lueck at web.de
Wed Dec 23 14:17:52 CET 2015


Discussing with Reinhard Kotucha, Philip Taylor argued
 
> P.S. I think the following demonstrates why \@undefined is
> markedly inferior to \ifcsname :
[etc.]

probably meaning inferiority of \LaTeX's \@ifundefined to the
\varepsilon-\TeX primitive \ifcsname, in that \@ifundefined
uses \csname and thus may assign a meaning to a named token
that before didn't have a meaning, or simply may increase the
hash table without increasing functionality. Both the two of
them (the German comedian equivalent may be "die zwei beiden")
also referred to a similar discussion on the list many years
ago (Phil provided the URL).

I would like to remind readers of a third approach that uses
\csname and though does not increase the hash table
(permanently -- made in Germany): Bernd Raichle's german.sty
has (had)

    \begingroup\expandafter\expandafter\expandafter\endgroup
    \expandafter\ifx\csname ProvidesPackage\endcsname\relax

So definedness of \ProvidesPackage as \ifx-equivalent to 
\relax is restricted to a local group, outside true 
undefinedness is not affected.

There could be a variant \@IfUndefined of \@ifundefined with 
an only local side effect as follows:

    \def\@IfUndefined#1{%
        \begingroup\expandafter\expandafter\expandafter\endgroup
        \expandafter\ifx\csname #1\endcsname\relax
              \expandafter\@firstoftwo
        \else \expandafter\@secondoftwo \fi}

>From Germany with love

 -- Uwe.


P.S.: I have ignored \varepsilon-\TeX\ until very recently ...
sympathizing with minimalistic implementations of \TeX. On
the other hand, I don't agree much when I read that the NTS
project "failed" -- \varepsilon-\TeX\ has been a useful result.



More information about the texhax mailing list