globalAssignFunction -- the standard function which can be used as a method for GlobalAssignHook so that certain types of mutable hash tables X, when assigned to a global variable, will acquire the name of the global variable as their name. The companion function globalReleaseFunction is used to release the name when the global variable gets reassigned.
The current way this function works is by storing the string used for printing under X.name and storing the global variable under X.Symbol.
Another thing done by this function is to apply use to the thing. This is used for polynomial rings to assign values to the symbols representing the variables (indeterminates) in the ring.
i1 : X = new Type of MutableHashTable |
i2 : x = new X |
i3 : X.GlobalAssignHook = globalAssignFunction |
i4 : X.GlobalReleaseHook = globalReleaseFunction |
i5 : x' = new X |
i6 : t = {x,x'} |
i7 : x = x' = 44 |
i8 : t |
i9 : code globalAssignFunction |
See also:
Code:
-- ../../../Macaulay2/m2/classes.m2:74-80 globalAssignFunction = (X,x) -> ( if not x#?(symbol name) then ( x.Symbol = X; x.name = string X; ); use x; )