Macaulay2 » Documentation
Packages » Macaulay2Doc :: value(String)
next | previous | forward | backward | up | index | toc

value(String) -- evaluate a string

Synopsis

Description

The contents of s are treated as code in the Macaulay2 language, parsed it in its own scope (the same way a file is) and evaluated. The string may contain multiple lines.
i1 : value "2 + 2"

o1 = 4
i2 : value "a := 33
     a+a"

o2 = 66
i3 : a

o3 = a

o3 : Symbol
Since the local assignment to a above occurred in a new scope, the value of the global variable a is unaffected.

During evaluation of the string, error messages will refer to the location of the error as currentString with a line number and a column number, and the value of the variable currentString is set to the string, to aid in debugging.

i4 : debuggingMode = stopIfError = false;
i5 : value "1/0"
currentString:1:2:(3):[1]: error: division by zero
i6 : debuggingMode = true;
i7 : value "1/0"
currentString:1:2:(3):[1]: error: division by zero
currentString:1:2:(3):[1]: --entering debugger (type help to see debugger commands)
currentString:1:0-1:2: --source code:
1/0
ii8 : break

See also

Ways to use this method: