globalAssignFunction

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 : GlobalAssignHook X := globalAssignFunction

o3 = globalAssignFunction

o3 : Function

'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.
i4 : GlobalReleaseHook X := globalReleaseFunction

o4 = globalReleaseFunction

o4 : Function

'globalReleaseFunction' -- the standard function which can be used as
     a method for 'GlobalReleaseHook' so that certain types of things, which
     have acquired as their name the name of a global variable to which they have
     been assigned, will lose that name when a different value is assigned to
     the variable.
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 = -- ../../m2/name.m2:10-16
     globalAssignFunction = (X,x) -> (
          if not x#?(quote name) then (
               x.symbol = X;
               x.name = string X;
               );
          use x;
          )

o9 : Net

See also name, symbol, and SelfInitializingType.


topindexpreviousupnext