# [tex-eplain] Bug(?) in \newcommand

Daniel Henry Luecking luecking at uark.edu
Wed Sep 12 20:49:29 CEST 2012

Hello:

(see below). This atempts to \edef the macro and leads to errors in simple cases:

\input eplain
\newcommand\y{\gobble}
\bye

Of course the error is
! Argument of \gobble has an extra }
But this is certainly a valid way to define \y, as long as one
does not try to expand its replacement text.

The definition of \newcommand comes from btxmac.tex, so perhaps
there is a reason for bibliographies to use \edef. I have never
used \newcommand in \eplain directly. I only encountered the error
when a supposedly plain.tex compatible file performed a test
\expandafter\ifx\csname newcommand\endcsname\relax
and then tried to \newcommand something instead of \def-ing it.

The questionable eplain.tex/btxmac.tex code follows. The \edef
occurs in the first line of \@newcommand, but is only invoked
in the last one:
\def\@newcommand#1{%
\def\@startdef{\expandafter\edef\@commandname}%
%
% The remainder of this long definition is irrelevant.
%
\expandafter\@startdef\@paramdef{#1}%
}%

Dan

Daniel H. Luecking
Department of Mathematical Sciences
University of Arkansas
Fayetteville, Arkansas