next | previous | forward | backward | up | top | index | toc | home

ReverseDictionary -- table of symbols where various types of objects are stored

Description

If a type of object has been registered with globalAssignment, and then an object of that type is assigned to a global symbol, then the symbol is stored in the hash table ReverseDictionary using the object as the key. This allows the object to print out with the same name as the symbol.
i1 : ZZ[x..y]

o1 = ZZ [x, y]

o1 : PolynomialRing
i2 : o1

o2 = ZZ [x, y]

o2 : PolynomialRing
i3 : R = o1

o3 = R

o3 : PolynomialRing
i4 : o1

o4 = R

o4 : PolynomialRing
i5 : o1^6

      6
o5 = R

o5 : R-module, free
i6 : ReverseDictionary#o1

o6 = R

o6 : Symbol

See also

Code

-- startup.m2:172-175
     globalAssignFunction = (X,x) -> (
          if not ReverseDictionary#?x then ReverseDictionary#x = X;
          use x;
          );
-- ../../../../Macaulay2/m2/orderedmonoidrings.m2:43-45
net PolynomialRing := R -> (
     if ReverseDictionary#?R then toString ReverseDictionary#R
     else net expression R)

For the programmer

The object ReverseDictionary is a mutable hash table.