pi.tex, I discovered the trick of using
\fontdimen as an array of dimensions (which is equivalent to storing integers between ±(2^31-1)sp). Namely,
\font\x=cmr10 at 1sp % or whatever font that is not used in the document. \fontdimen 10000 \x = 1pt \showthe\fontdimen 10000 \x % => 1pt \bye
This method of storage appears to be very efficient memory-wise (in TeXLive 2012, pdfTeX and XeTeX are happy to store a bit less than 3000000 such parameters, LuaTeX extends memory as needed), and speed-wise (I benchmarked access and modification to be just as fast as for usual dimen registers, once the space has been allocated).
The main drawback I see is that the size of the array must be declared as soon as the new font is introduced (or rather, before another font is defined):
\font\x=cmr10 at 1sp \font\y=cmr10 at 2sp \fontdimen1000\x=1pt % => error: '\x only has 7 fontdimen parameters' \bye
Are there any other drawbacks to using font memory for the storage of large amounts of data? Is it frequent for a document to reach the bounds of […]TeX's font memory (in which case I shouldn't use it for other purposes than fonts)? If not, I am thinking of using this technique for
l3regex, and perhaps to store some tables of values for