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

globalAssignFunction -- the standard method for the global assignment hook

Description

globalAssignFunction -- the standard function which 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 = -- startup.m2:169-172
          globalAssignFunction = (X,x) -> (
               if not ReverseDictionary#?x then ReverseDictionary#x = X;
               use x;
               );

See also