Macaulay2 » Documentation
Packages » Macaulay2Doc » The Macaulay2 language » Thing » Symbol » GlobalAssignHook
next | previous | forward | backward | up | index | toc

# GlobalAssignHook -- hook for assignment to global variables

- Usage:
    `X.GlobalAssignHook = f`
- Inputs:
  - X, a type
  - f, a function, of two variables: the symbol to which a value is about to be assigned, and the value being assigned
- Consequences:
  - f will be called just before an assignment to a global variable of an instance of class X occurs

## Description

This technique is used, for example, for instances of Type and Ring to arrange for the name of the type or ring to be set to the name of the global variable to which it is first assigned. The functions globalAssignFunction and globalReleaseFunction may installed as methods for this purpose.

    i1 : RR.GlobalAssignHook = (sym,val) -> << "--about to assign " << val << " to " << sym << endl;

    i2 : a = 4.5
    --about to assign 4.5 to a

    o2 = 4.5

    o2 : RR (of precision 53)

## See also

- GlobalReleaseHook

## For the programmer

The object GlobalAssignHook is a symbol.

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Macaulay2Doc/ov_repl.m2:279:0.