Will Robertson <[log in to unmask]> writes:
> On 22 Jun 2018, at 5:54 am, David Kastrup <[log in to unmask]> wrote:
>> A stupid question that just occured to me: should we be discouraging
>> registering prefixes that match another prefix' contribution to the
>> overly simplistic hash function used in almost all TeX engines?
> Would it be easier to update the hash function in the engines? :)
> What would be the easiest way to test for clashes?
Well, the hash function is just
@<Compute the hash code |h|@>=
for k:=j+1 to j+l-1 do
while h>=hash_prime do h:=h-hash_prime;
So basically it's multiplying the ASCII codes by increasing powers of
two from right to left before reducing modulo hash_prime. hash_prime
will tend to stay around for a few years until getting bumped but there
will be collisions even before the modulo operation.
Prefixes will tend to be less than 20 letters, so any programming
language offering 32bit integers should be fine for finding collisions
even before reducing modulo hash_prime.