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

symbolBody -- symbol bodies


A Macaulay2 symbol is much like a function closure, in that it comes equipped with a pointer to a frame that contains a value for it. That value can be recovered with the function value, as follows.

i1 : f = x -> symbol x

o1 = f

o1 : FunctionClosure
i2 : s = f 1

o2 = x

o2 : Symbol
i3 : t = f 2

o3 = x

o3 : Symbol

The two symbols created in the example above have something in common -- they are created by the same bit of code (the function f), but they have different values.

i4 : value s

o4 = 1
i5 : value t

o5 = 2

To allow the user to determine whether two symbols are created by the same bit of code, Macaulay2 has the notion of symbol body, which parallel to the notion of function body. It's essentially the symbol, but without the pointer to the frame that contains the value.

i6 : symbolBody s

o6 = x

o6 : SymbolBody
i7 : symbolBody t

o7 = x

o7 : SymbolBody
i8 : symbolBody s === symbolBody t

o8 = true

All such symbol bodies are members of the class SymbolBody.

i9 : class symbolBody s

o9 = SymbolBody

o9 : Type

For the programmer

The object symbolBody is a compiled function.