Macaulay2 » Documentation
Packages » Macaulay2Doc :: globalAssignFunction
next | previous | forward | backward | up | index | toc

globalAssignFunction -- the standard method for the global assignment hook

Description

globalAssignFunction -- the standard function that can be used as a method for GlobalAssignHook so that certain types of things, 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.

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

o1 = X

o1 : Type
i2 : x = new X

o2 = X{}

o2 : X
i3 : X.GlobalAssignHook = globalAssignFunction

o3 = globalAssignFunction

o3 : FunctionClosure
i4 : X.GlobalReleaseHook = globalReleaseFunction

o4 = globalReleaseFunction

o4 : FunctionClosure
i5 : x' = new X

o5 = x'

o5 : X
i6 : t = {x,x'}

o6 = {X{}, x'}

o6 : List
i7 : x = x' = 44

o7 = 44
i8 : t

o8 = {X{}, X{}}

o8 : List
i9 : code globalAssignFunction

o9 = /usr/local/share/Macaulay2/Core/startup.m2.in:234:34-
     237:14: --source code:
          globalAssignFunction = (X,x) -> (
               if not instance(X,Symbol) then error("globalAssignFunction: expected a symbol: ", toString X);
               if not hasAttribute(x,ReverseDictionary) then setAttribute(x,ReverseDictionary,X);
               use x;
               );

See also

For the programmer

The object globalAssignFunction is a function closure.