integers vs fp numbers

Alan Jeffrey ajeffrey@cs.depaul.edu
Sat, 17 Oct 1998 22:00:54 -0500


Vladimir asked: can fontinst be reengineered to use fp numbers rather than
integers where sensible?

Pretty much the answer's no.  At least the reengineering would be pretty
drastic, and would have pretty major efficiency impact.  There's (off the
top of my head) three representations TeX uses for ints which are used
inside fontinst:

a) registers (efficient, but there's only 256 of them)

b) mathchars: for people who've not seen this particular bit of
entertainment, TeX allows \mathchardef's for things like
\mathchardef\alpha=...some int representation of the family/slot pair...
DEK intended for this to be used for math characters (duh like you couldn't
guess) but (like \uppercase) DEK's intensions and the rest of the world's
use is rather different.  Fontinst uses \mathchardef's as an efficient 
representation of non-negative ints.  \mathchardef's are almost as efficient
as registers, and there's as many of them as you like.

c) textual representation: in the cases where you can't assign a
\mathchardef (notably for negative numbers) fontinst just does a \def, eg
\def\foo{-123}.

So changing representation a) from ints to fp wouldn't be hard, but most of
fontinst variables aren't stored this way.

Most are b) and some are c).  There's no equivalent of b) for fp numbers,
and I'm not sure I want to think about what would happen to the runtime if
we went to c) for fp numbers (eg \def\foo{123.456789} so tripling the amount
of memory used and the number of tokens which need to be manipulated for
each arithmetic op.

This is one of TeX's big limitations I'm afraid.  TeX is much better at
storing / manipulating ints than fp numbers.  So any redesign to use fp
would be pretty serious.

Alan.