[tex-k] C299: r not declared with the proper type

胡亚捷 (Hu Yajie) 2500418497 at qq.com
Sun May 2 15:13:42 CEST 2021

During the 2021 tuneup, Knuth changed the Bernshtein macros on C299
so that the last four lines became

    primarydef t Bernshtein nn = begingroup save r; r =
     begingroup for n=nn downto 2:
      for k=1 upto n-1: u_[[[k]]]:=t[[[u_[[[k]]],u_[[[k+1]]] ]]];
      endfor endfor u_[[[1]]] endgroup; numeric u_[[[]]];
     r endgroup enddef;

    (The tokens [[[ and ]]] are primitive versions of [ and ]. --Hu)

This introduced another bug: The temporary variable r is not declared
with the proper type, so it is numeric. Then it is assigned the value
of u_[[[1]]], which can be either numeric or pair as shown earlier in
the code. METAFONT won't let you assign a pair to a numeric variable.

You might want to fix this by saying "if pair u_[[[1]]]: pair r; fi"
before the assignment, but the page is already full.

And, as I said in January, it solves the "show" problem inadequately.
Namely, "show .5[2a,2b,2c,2d]" now gives explicit results, but "show
.5[3a,3b,3c,3d]" and "show 2[a,b,c,d]" fail. (Hence my TUGboat article.)

Since it solves one problem inadequately and introduces another,
maybe it's better to revert it and use the pre-2021-tuneup version?


By the way, .5[a,b] is a primary expression but .5[a,b,c] isn't. Thus in

    z1 .. controls t[z1,z2] and (t[z1,z2,z3]) .. t[z1,z2,z3,z4]

the parentheses around t[z1,z2,z3] is necessary. There seems to be no way
to make Bernstein work on the primary level, despite the "primarydef".

More information about the tex-k mailing list.