You can use \@gobble
, for instance, to restrict the usage of a macro like:
\documentclass{article}
\makeatletter
\newcommand*{\cmd}[1]{%
\textbf{#1}
\let\cmd\@gobble
}
\makeatother
\begin{document}
\cmd{Hello World!}
\cmd{Again...}%not desirable
\end{document}
But, if you have a command with an optional argument, e.g. \newcommand{\cmd}[2][]{#1 #2}
, there is no kernel macro that helps you. Sure, you could define something like
\newcommand{\@gobble@opt}[2][]{}
%\newcommand{\RG@gobble@opt}[2][]{}%alt: to avoid possible name clashes
Is this the usual way? Is it, generally speaking, absurd to gobble like this?
\let\cmd\@gobble
is not really sufficient: you should add something more with\@bsphack
and\@esphack
.