M2
M2 copied to clipboard
doubly nested cache table
This extra cache table should not be there:
Macaulay2, version 1.16.0.2
with packages: Colon, ConwayPolynomials, Elimination, IntegralClosure, InverseSystems, LLLBases, MinimalPrimes, PrimaryDecomposition, ReesAlgebra, TangentCone, Truncations
i1 : M = ZZ^2;
i2 : peek M.cache
o2 = CacheTable{cache => MutableHashTable{}}
i3 :
Process M2 finished
+ /Applications/Macaulay2-1.16/bin/M2 --no-readline --print-width 92
Macaulay2, version 1.16
with packages: ConwayPolynomials, Elimination, IntegralClosure, InverseSystems, LLLBases,
MinimalPrimes, PrimaryDecomposition, ReesAlgebra, TangentCone, Truncations
i1 : M = ZZ^2;
i2 : peek M.cache
o2 = CacheTable{cache => MutableHashTable{}}
I didn't expect this to return much, but here are a few places it seems to be used:
[mahrud@noether M2]$ grep -R "cache.cache\b" Macaulay2/
Macaulay2/m2/modules2.m2: Y := youngest(M.cache.cache,N.cache.cache);
Macaulay2/m2/modules2.m2: Y := youngest(M.cache.cache,N.cache.cache);
Macaulay2/packages/Complexes.m2: Y := youngest(M.cache.cache,N.cache.cache);
Macaulay2/packages/Complexes.m2: peek N.cache.cache -- why does N.cache have its own cache table?
Macaulay2/tests/normal/hom.m2:assert ( hash (Hom(M,N)).cache.cache === hash (Hom(M,N)).cache.cache )
Macaulay2/tests/normal/hom.m2:assert ( hash (M**N).cache.cache === hash (M**N).cache.cache )
Note the second occurrence in Complexes.m2 😂
Oh, did this issue come up in relation to #1570?
Oh, maybe this comment explains it:
new Module from Sequence := (Module,x) -> (
(R,rM) -> (
assert instance(R,Ring);
assert instance(rM,RawFreeModule);
new Module of Vector from hashTable {
symbol cache => new CacheTable from {
cache => new MutableHashTable -- this hash table is mutable, hence has a hash number that can serve as its age
},
symbol RawFreeModule => rM,
symbol ring => R,
symbol numgens => rawRank rM
})) x
Cache tables are also mutable, but their hash codes are always 0. Modules are immutable, so there's no way to figure out their age.
Maybe there's a cleaner way to arrange it. Oh, well, not urgent.
Oh, did this issue come up in relation to #1570?
No.
Oops, I keep forgetting to work on that for them.
Cache tables are also mutable, but their hash codes are always 0. Modules are immutable, so there's no way to figure out their age.
Perhaps in order to avoid confusion M.cache.cache shouldn't be called cache, because it's just a MutableHashTable and not a CacheTable. Or perhaps M.cache should be a MutableHashTable instead. Would that break ===?