It looks like `forget` works on procedures with option 'cache'.

I realize that there is a routine Cache:-RemovePermanent. But should `forget` be clearing the permanent Cache entries for a procedure?

> cacheFunc := proc() option cache; print(args); args; end proc:
> Cache:-AddPermanent( cacheFunc, [5], 10 );
> op( 4, eval(cacheFunc) );
                      Cache(512, 'permanent' = [5 = 10])
 
> forget(cacheFunc);
> op( 4, eval(cacheFunc) ); # NULL return, it's empty

Why does the above clear the permanent entries from cacheFunc's cache while this does not clear permanent Cache entries for BesselJ?

> restart:
> op(4,eval(BesselJ));
                    Cache(512, 'permanent' = [(0, 0) = 1])
 
> forget(BesselJ);
> op(4,eval(BesselJ));
                    Cache(512, 'permanent' = [(0, 0) = 1])

At first I imagined that the difference might come from the fact that BesselJ does not have `option cache` even though there are Cache entries for it. But if I define cacheFunc without `option cache` then it still gets cleared by `forget`.

> restart:
> cacheFunc := proc() print(args); args; end proc:
> Cache:-AddPermanent( cacheFunc, [5], 10 );
> op( 4, eval(cacheFunc) );
                      Cache(512, 'permanent' = [5 = 10])
 
> forget(cacheFunc);
> op( 4, eval(cacheFunc) ); # NULL return

What's the key difference here? (I didn't try saving to an archive, prior to restarting...) I feel that I must be missing something simple.

 

I note that the help-page ?CacheOption has a cross-reference to `forget` in its "See Also" section, but otherwise doesn't mention how it works with `forget`. And the help-page ?forget is silent about caches.

If someone writes a forget('all') routine then maybe it should have an optional argument to control whether permanent cache entries get cleared. I wouldn't be surprised if clearing the permanent Cache entries for BesselJ or some other routines might break things, though.


Please Wait...