On Tue, May 19, 2026 at 09:00:47PM +0800, Qian Yun wrote:
> Although this 'enterInCache' is not used in Kernel (the other
> signature is used), this is still a logical error.
> 
> Because of the usage of DIFF elsewhere, we can not assume
> "1 + cache_use" is the biggest position.
> 
> Instead, we should use logic like elsewhere: bump position
> by DIFF.

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

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/fricas-devel/ag-N2F_xJhWvXLt-%40fricas.org.

Reply via email to