When you
\def\foo{}
you are giving \foo
an empty definition, but \foo
still 'exists' using any of the tests used for this (such as \ifdefined
or LaTeX's \@ifundefined
). The same effect can be achieved by doing
\let\foo\empty
which is very slightly more efficient as it points to an already-used memory location (not a worry nowadays). When \foo
has such a definition, it is expandable, and so
\edef\baz{\foo}
will result in \baz
being empty, as \foo
expands to nothing at all.
On the other hand
\let\foo\relax
makes \foo
equal to the \relax
primitive. That is a 'do nothing' operation, but importantly is not expandable. So in this case
\edef\baz{\foo}
leaves \baz
with definition '\foo
'. That can be useful: it's a way of temporarily preventing a macro from doing anything while retaining it's appearance in other code. On the other hand, sometimes you don't want that: it depends on the context. When \foo
is equal to \relax
, whether it is regarded as 'existing' by the various tests is more variable. TeX automatically creates control sequences equal to \relax
in various cases, and so some tests will regard anything equal to \relax
as 'not defined'.
So which is better depends on your use case.
In LISP, it returns the first element of a list or a pair. In LaTeX, its definition is \def\@car#1#2\@nil{#1}
(defined right before \def\@cdr#1#2\@nil{#2}
), and it is defined in LaTeX core (latex.ltx
).
The origins of the word come from the architecture of some early IBM computers.
Best Answer
It grabs the content until the next brace (or group). For example:
gives