
% This style makes available \newdef and \renewdef.  These are to be
% used like \newcommand and \renewcommand, respectively, and in
% effect make the same macro those would only such that it requires
% braces around its arguments.  You may make zero-argument macros
% with \newdef\mymacro{...}, which is exactly the same as using
% \newcommand instead, or with \newdef\mymacro[0]{...}, which also
% makes \mymacro takes no arguments but causes it to require that it
% be followed by an open brace (so that you can be sure it won't
% gobble following spaces).



\def\newdef{\let\ndf@command\newcommand\ndf@start}
\def\renewdef{\let\ndf@command\renewcommand\ndf@start}
\def\ndf@start#1{\def\ndf@todef{#1}\futurelet\ndf@future\ndf@check}
\def\ndf@check{%
  \begingroup
    \if\ndf@future[\aftergroup\new@def \else \aftergroup\ndf@command \fi
    \expandafter\aftergroup\ndf@todef
  \endgroup
}

\newcount\ndf@n
\newtoks\ndf@toks

\expandafter\newtoks\csname ndf-1\endcsname
\expandafter\newtoks\csname ndf-2\endcsname
\expandafter\newtoks\csname ndf-3\endcsname
\expandafter\newtoks\csname ndf-4\endcsname
\expandafter\newtoks\csname ndf-5\endcsname
\expandafter\newtoks\csname ndf-6\endcsname
\expandafter\newtoks\csname ndf-7\endcsname
\expandafter\newtoks\csname ndf-8\endcsname
\expandafter\newtoks\csname ndf-9\endcsname

% make #1 effectively take #2 args and do #3
\long\def\new@def#1[#2]#3{%
  \ifnum#2=0%
    \long\def#1##{#3}%
  \else
    \expandafter\ndf@command\csname ndf-\string#1\endcsname[#2]{#3}%
    \def#1{%
      \def\ndf@doas####1{\let#1=####1#1}%
      \ndf@toks={\csname ndf-\string#1\endcsname}%
      \ndf@n=#2%
      \begingroup
        \aftergroup\edef
        \aftergroup\ndf@doit
        \aftergroup{\iffalse}\fi
        \aftergroup\the
        \aftergroup\ndf@toks
        \ndf@doas\ndf@look
    }%
  \fi
}

\def\ndf@lose#{\newdef@is@losing}
\def\ndf@ok{\ndf@ok}
\def\ndf@exam#1#2\ndf@exam@over{\ifx#1\ndf@ok\else\ndf@doas\ndf@lose#1#2\fi}
\def\ndf@look#1#{\ndf@exam#1\ndf@ok\ndf@ok\ndf@exam@over\ndf@doas\ndf@step}

\long\def\ndf@step#1{%
  \global\csname ndf-\the\ndf@n\endcsname={#1}%
  \aftergroup{%
  \aftergroup\the
  \expandafter\aftergroup\csname ndf-\the\ndf@n\endcsname
  \aftergroup}%
  \advance\ndf@n by -1
  \ifnum\ndf@n>0\let\ndf@go\ndf@look\else\let\ndf@go\ndf@end\fi
  \ndf@doas\ndf@go
}

\def\ndf@end{%
    \iffalse{\fi\aftergroup}%
    \aftergroup\ndf@doit
  \endgroup
}
