[tex-live] No room for a new \write

Heiko Oberdiek oberdiek at uni-freiburg.de
Sat Mar 17 10:49:51 CET 2007

On Sat, Mar 17, 2007 at 08:42:45AM +0000, Robin Fairbairns wrote:

> Reinhard Kotucha <reinhard.kotucha at web.de> wrote:
>
> > A limit of 32 files which can be open at the same time sounds
> > ridiculously nowadays.  Yes, TeX (the program) allows you to have 16
> > read and 16 write streams open at the same time.  But the plain TeX
> > macros (which are used by LaTeX too) are extremely inefficient.
> >
> > Register allocation is currently stack based.  If you say
> > \newwrite\foo, then \foo is is associated with \write0.  If you then
> > say \newwrite\bar, \bar is is associated with \write1, and so on.
> >
> > The stack pointer is increased whenever you say \newwrite but nothing
> > useful happens if you say \closeout.
> >
> > The alternative would be to make file allocation list based.
>
> peter wilson's newfile package does just that.

\newoutputstream calls \newwrite, \openoutputfile calls \openout,
and \closeoutputstream calls \closeout. As far as I can see,
the package just provides an more convenient interface for writing and
reading. It does not change the stream allocation. There aren't
commands that free or reuses a stream.

> of course, it only works (as david k has pointed out) if users use its
> mechanisms exclusively, rather than trying to be "clever".

* Sometimes it isn't necessary to use a separate output stream,
because LaTeX's .aux files can be used instead.
* Some package write files in the scope of chapters, e.g. minitoc:
%  Jun/Jul-93   New design, to avoid allocating a newwrite
%               for each chapter (!)
* Several output files can be written to one file first and
splitted later, see package splitindex.
* Another method is implemented in docstrip. It can generate all
output files in one run, if there are enough write registers.
Or it processes the .dtx files several times until all files
are written.

I don't know and don't understand why the number of write/read
registers weren't increased in e-TeX like other registers.
Write nodes have enough place for storing much larger register
numbers.

Yours sincerely
Heiko <oberdiek at uni-freiburg.de>