Exactly as muzimuzhi said: \deferred
is a LuaTeX alternative to the shipout
keyword. That is, both should do the exact same thing.
The shipout
keyword was implemented in pdfTeX (and copy-pasted ported to XeTeX, e(u)-pTeX, and Aleph) because we needed a “late expansion” for \special
. When Hans implemented it for LuaTeX, he probably thought a \deferred
prefix is better because it's symmetric to \immediate
. muzimuzhi already answered your question spot-on, so here's an explanation of what \deferred
or the shipout
keyword are for:
When you use \special
, it fully expands the argument (pretty much like \expanded
), then adds the expanded token list as a whatsit node to the output list. That node is then written as-is to the output .pdf
or whatever format the engine produces.
The problem with that, is that when TeX is reading your \special
, it doesn't know it what page that \special
will be placed, so using things like \thepage
will sometimes give the wrong information.
In the example (pdfTeX) document below, we are typesetting one long paragraph across three pages: at the time TeX reads the \special
(when it is building the horizontal list for the paragraph), it is still processing the first paragraph in page 1 (first it builds the list of nodes, then it breaks the list into lines, then those lines across pages), so \count0
(the page number) is 1, so it colours the text red.
If you switch to \special shipout
it will hold the token list unexpanded until the page shipout (when everything is in its final position in the page), and only then it expands the token list, and evaluates the value of \count0
. At this point, TeX already knows it's on page , so it colours blue.
\input color.tex
\hsize=5cm \pdfpagewidth=10cm
\vsize=5cm \pdfpageheight=10cm
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\special{pdf:%
% \special shipout{pdf:%
\ifnum\count0=1 1 \else 0 \fi 0 \ifnum\count0=1 0 \else 1 \fi rg
\ifnum\count0=1 1 \else 0 \fi 0 \ifnum\count0=1 0 \else 1 \fi RG}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\bye
With \special
:

With \special shipout
(or \deferred\special
in LuaTeX):

All of this was already possible without these extensions, but it required you to run TeX multiple times to make TeX write your \special
on the page, then find out where it ended up, and then use that information (stored in a temporary file) to do the right choice later. This extension lets you do all in one go, without extra data structures and build steps.