# How does \halign differ from \hfil?

Suppose we have three blocks of text aligned horizontally. Why Example 1 differs from Example 2 and what should be changed in the latter to make it look like the former?

NOTE: I added rules just to indicate visually the placements of blocks of text.

Example 1

\def\text{%
Inde igitur, inquit,
ordiendum est. Tibi
hoc incredibile, quod
beatissimum.
}
\long\def\vtopragged#1#2{\vrule\kern-.4pt\vtop{\prevdepth=2pt\hsize=#1 \raggedright #2}\vrule\kern-.4pt}
\begingroup
\parindent=0pt
\tabskip=0pt
\topskip=0pt
\hrule
\kern-.4pt
\halign to\hsize{%
\vtopragged{.2\hsize}{#}\tabskip=0pt plus 1fill &
\vtopragged{.2\hsize}{#}\tabskip=0pt plus 1fill &
\vtopragged{.2\hsize}{#}\tabskip=0pt \cr
\text&
\text&
\text\cr
}
\hrule
\kern-.4pt
\endgroup
\bye


Example 2

\def\text{%
Inde igitur, inquit,
ordiendum est. Tibi
hoc incredibile, quod
beatissimum.
}
\long\def\parbox#1{%
\vtop{
\hsize0.2\hsize
\parindent0pt
\raggedright
#1\par
}%
}
\topskip=0pt
\hrule
\noindent
\vrule height 10pt
\parbox{\text}\hfil
\vrule
\parbox{\text}\hfil
\vrule
\parbox{\text}
\vrule
\hrule
\bye


Apart from the missing rules, the difference is that \halign doesn't care about \parfillskip, because it makes a box in vertical mode. You use \hfil in the second example, which can't kill \parfillskip. Things go smoothly if you use \hfill.

\def\text{%
Inde igitur, inquit,
ordiendum est. Tibi
hoc incredibile, quod
beatissimum.
}
\long\def\vtopragged#1#2{\vrule\kern-.4pt\vtop{\prevdepth=2pt\hsize=#1 \raggedright #2}\vrule\kern-.4pt}

\begingroup
\parindent=0pt
\tabskip=0pt
\topskip=0pt
\hrule
\kern-.4pt
\halign to\hsize{%
\vtopragged{.2\hsize}{#}\tabskip=0pt plus 1fill &
\vtopragged{.2\hsize}{#}\tabskip=0pt plus 1fill &
\vtopragged{.2\hsize}{#}\tabskip=0pt \cr
\text&
\text&
\text\cr
}
\hrule
\kern-.4pt
\endgroup
\bigskip

\long\def\parbox#1{%
\vtop{
\hsize0.2\hsize
\parindent0pt
\raggedright
#1\par
}%
}
\topskip=0pt
\hrule
\noindent
\vrule
\parbox{\text}\vrule\hfill\vrule
\parbox{\text}\vrule\hfill\vrule
\parbox{\text}\vrule
\hrule
\bye


Note that using fill units in \tabskip has no influence, because fil would suffice (\halign to \hsize is similar to \hbox to \hsize); compare the output when fil is used in the first example and \hfil in the second one, where the effect of \parfillskip is clearly seen.