From the answer to my other question " How can I define a math operator behaving like \lim or \sum with limits?", I tried:
\def\ext{\qopname\relax m{ext}}
and:
\newcommand{\ext}{\qopname\relax m{ext}}
In " What is the difference between \def and \newcommand?", it is said that they are basically the same and \newcommand is a bit more clever and does some extra checks. But it suggests that they should behave in just the same way.
But actually they do not. For the \def case, it seems to add extra spacing around \ext when I use it (just like \lim would). And \newcommand does not.
Why? What exactly is the different behavior for those more generally?
\defis more like\newcommand*. For the same behavior of\newcommandyou would need\long\def, but this does only matter if you define macros with arguments. Could you add a minimal example that shows the space you mention. – Martin Scharrer Mar 16 '11 at 10:18\defas it overwrites existing macros without question. Usually one should only overwrite a macro if on know what it does and one is certain it will be OK to overwrite it. The classical example is of course\span– daleif Mar 16 '11 at 10:27\qopname. I don't know what Stefan suggested that. You should be using\DeclareMathOperatorin the preamble, or for one-off, you should be using\operatorname. – TH. Mar 16 '11 at 19:13\qopname. Still I agree with your recommendations. – Hendrik Vogt Mar 17 '11 at 07:50\limis defined that way for efficiency since they knew thatlimdidn't need any mathcode modifications. Grantedextdoesn't either, but that's not really a good reason to use an undocumented macro rather than the standard interface. – TH. Mar 17 '11 at 14:52:-)– Hendrik Vogt Mar 17 '11 at 14:54