SAGE provides a unified interface to the best computational software. This is accomplished using both C-libraries (see Chapter 5) and interpreter interfaces, which are implemented using pseudo-tty's, system files, etc. This chapter is about these interpreter interfaces.
2+2
thousands of times using the GAP
interface will be slower than doing it directly in SAGE. In
contrast, the C-library interfaces of Chapter 5
incur less overhead.
In addition to the commands described for each of the interfaces
below, you can also type e.g., %gap
, %magma
, etc., to
directly interact with a given interface in its state. Alternatively,
if X
is an interface object, typing X.interact()
allows
you to interact with it. This is completely different than
X.console()
which starts a complete new copy of whatever
program X
interacts with. Note that the input for
X.interact()
is handled by SAGE, so the history buffer is the
same as for SAGE, tab completion is as for SAGE (unfortunately!),
and input that spans multiple lines must be indicated using a
backslash at the end of each line. You can pull data into an
interactive session with X
using sage(expression)
.
The console and interact methods of an interface do very different things. For example, using gap as an example:
gap.console()
: You are completely using another
program, e.g., gap/magma/gp
Here SAGE is serving as nothing more than a convenient
program launcher, similar to bash.
gap.interact()
: This is a convenient way to interact
with a running
gap instance that may be "full of" SAGE objects. You can
import SAGE objects into this gap (even from the interactive
interface), etc.
The console function is very useful on occasion, since you get the exact actual program available (esp., useful for tab completion and testing to make sure nothing funny is going on).