It is not clear to me if we should consider this to be a bug,
AFAICS the intent was to choose and use one of 'enterInCache'
functions, not both together. And if you really what to
mix them, then adding DIFF is not enough. Multiplying by
DIFF probably would be enough. But more sensible approach
would be to remove first 'enterInCache' from SortedCache
and possibly create a now domain, say 'LinearCache'
which do not require order and uses linear search.
> diff --git a/src/algebra/kl.spad b/src/algebra/kl.spad
> index 0365b60f..143f73c4 100644
> --- a/src/algebra/kl.spad
> +++ b/src/algebra/kl.spad
> @@ -116,7 +116,11 @@ SortedCache(S : CachableSet) : Exports == Implementation where
>
> enterInCache(x : S, equal? : S -> Boolean) ==
> (res := linearSearch(equal?)) case S => res
> - setPosition(x, 1 + cache_use)
> + if cache_use = 0 then
> + pos : N := DIFF
> + else
> + pos : N := DIFF + position cache(cache_use - 1)
> + setPosition(x, pos)
> insertAtEnd(x)
> x
>
--
Waldek Hebisch