[next][previous][up][top][index]
search for:

local variables in a file

There is a way to construct variables that can be used within a given source file, and are invisible to code placed in other files. We use := for this. Assume the code below is placed in a file, and that the file is loaded with the load command.

i1 : ff := 5

o1 = 5
i2 : ff

o2 = 5

The variable above is a local one. Its value is not available to code in other files.

Assume the code above is entered directly by the user into Macaulay 2. Then the variable is still a local one and is not available to code previously loaded or to functions previously defined, but it will be available to code loaded subsequently. We illustrate this below with the variable jj.

i3 : hh = () -> jj

o3 = hh

o3 : Function
i4 : hh()

o4 = jj

o4 : Symbol
i5 : jj = 444

o5 = 444
i6 : hh()

o6 = 444
i7 : jj := 555

o7 = 555
i8 : hh()

o8 = 444
i9 : jj

o9 = 555


[next][previous][up][top][index]
search for: