# [luatex] incompatible change to mathcode

Taco Hoekwater taco at elvenkind.com
Wed May 9 10:16:50 CEST 2012

```Hi all,

On 05/08/2012 09:11 PM, David Carlisle wrote:
>
> Luatex has changed mathcode to allow a larger numeric range however
> changing TeX primitives without giving them new names seems suspect and
> in this particular case, since \mathcode has changed but \mathchardef
> has not the essential link between these two commands has been broken.

Not quite. You get the results below because the math code for `a
has been set using \Umathcode, not the TeX82 \mathcode. In fact,
assignment to \mathcode is not extended in LuaTeX at all.

The output of \mathcode is indeed extended, and the value you get
uses the same format as the input for \Umathcodenum (with that
somewhat unusual XeTeX-invented format explained by Kazuki Maeda).

The reason for this is that math character objects in luatex remember
how they were defined. So if you do not want incompatibilities with
TeX82, it would help if you did not use extended primitives to define stuff.

That said, probably the result of (\the)\mathcode can be reverted
back to compatibility with TeX82, and output a warning (and zero)
if the actual value is out-of-range (like XeTeX does).