The code
\documentclass{article}
\begin{document}
\begingroup
\catcode`@\active
\def@#1\par{<#1>}
@some text
\endgroup
\end{document}
works flawlessly. Why not so when I replace it by the following?
\def@#1\space{<#1>}
The code
\documentclass{article}
\begin{document}
\begingroup
\catcode`@\active
\def@#1\par{<#1>}
@some text
\endgroup
\end{document}
works flawlessly. Why not so when I replace it by the following?
\def@#1\space{<#1>}
\def@#1\space{<#1>} doesn't work, unless TeX finds the token \space before the current paragraph ends.
Recall that TeX doesn't do expansion when
On the other hand,
\def@#1 {<#1>}
will work. Here's a Plain TeX example (so I'll use \tt):
\begingroup
\catcode`@\active
\def@#1 {{\tt<#1>}}
@some text
@some
\endgroup
\bye

However, you probably want to delimit the argument with the end-of-line. See Using end-of-line delimiter in plain Tex macro for this case.
There is a fundamental difference between \par and \space. The former is a primitive (unless redefined); TeX inserts automatically a \par token when it sees a category code 5 character when in state S (start of line), during the tokenization process. So
\def\foo#1\par{Something with #1}
and the call
\foo xyz
something else after a blank line
will correctly identify xyz (with a trailing space, though) as the argument to \foo.
The macro \space is defined by \def\space{ }, and there's no magic process that automatically inserts such a token.
\parappears when TeX tokenizes the end of lines (so the definition of@actually finds the\partoken because TeX inserts it).\spaceis a macro, but it doesn't appear “magically” like\par. You can use\def@#1 {<#1>}. – Manuel Apr 02 '15 at 15:08