redStart: function to start a REDUCE session

View source: R/redcas.R

redStartR Documentation

function to start a REDUCE session

Description

Starts a REDUCE session using a pipe connection sending the output (log) to a temporary file.

Usage

redStart(dialect = "csl", dirpath, options, echo=FALSE)

Arguments

dialect

character. The version of lisp with which the REDUCE executable was built. Allowed values are csl, the default, or psl.

dirpath

character. Path to a directory containing the REDUCE executables. Optional, see details below.

options

character. Options for the csl version. See details.

echo

boolean. Should the ECHO switch be turned on. Default is FALSE to match the REDUCE default.

Details

redcas finds the REDUCE executables in two different ways. The first is the explicit specification of the path using the dirpath argument passed to the redStart function. If this does not contain the REDUCE executable, redStart stops executing on the assumption that a specific version was intended.

The second method is used if dirpath is not specified. This determines the path at package load time by searching the following three locations in turn until the executable is found:

  • the environment variable REDUCE_EXEC exists and contains the path to a directory containing an executable;

  • the R option reduce_exec exists and contains the path to a directory containing the executable;

  • the REDUCE executable is found in a directory named in the environment variable PATH.

This approach provides the flexibility to have a default version while being able to call different versions explicitly.

While it is possible to start a second REDUCE session without closing the first, garbage collection closes its connection. A future release will fix this issue.

redStart carries out the following actions:

  • creates the REDUCE session using a pipe connection and sending the REDUCE output to a temporary file (in REDUCE terminology referred to as a log);

  • registers the session, acquiring a session identifier

  • calls redExec to load the REDUCE functions which are part of the package and to set the ECHO switch if requested.

  • returns the session identifier.

Value

The session identifier which is an integer >0 if the session started successfully. If the session could not be started, redStart terminates using stop. If no REDUCE executable was found returns FALSE.

Author(s)

martin gregory

See Also

showSessions to list active sessions and redClose for closing a session.

Examples

## Open a CSL session:
id1 <- redStart()
## can only run code if session was successfully started
if (is.numeric(id1)) {
   ## show session details:
   print(showSessions())
   ## close session:
   redClose(id1)
}

redcas documentation built on April 12, 2025, 1:40 a.m.