[top][index]
search for:

globalAssignFunction -- the standard method for the global assignment hook

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

o1 = X

o1 : Type
i2 : x = new X

o2 = X{...}

o2 : X
i3 : X.GlobalAssignHook = globalAssignFunction

o3 = globalAssignFunction

o3 : Function

  --  the standard method for the global assignment hook
i4 : X.GlobalReleaseHook = globalReleaseFunction

o4 = globalReleaseFunction

o4 : Function

  --  the standard method for the global variable release hook
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 = -- ../../../../../Macaulay2/m2/classes.m2:74-80
     globalAssignFunction = (X,x) -> (
          if not x#?(symbol name) then (
               x.Symbol = X;
               x.name = string X;
               );
          use x;
          )

See also:

  • name -- store the name of a hash table
  • symbol -- get a symbol
  • SelfInitializingType -- the class of all self initializing types
  • 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;
              )

    [top][index]
    search for: