The S Session

paragraph:

The S session begins by starting up an S process, from a shell or some other user interface. A session can be non-interactive, usually because S is invoked from the shell with a standard input that is not interactive (e.g., a file or the output piped from some other process). S makes some decisions based on whether the session (more precisely, the current evaluator) is interactive; for example, the parser prompts by default for interactive use only. Your own S functions can test by calling interactive(). The S session continues until the user quits, until there is no further source for possible tasks, or until something very nasty happens that causes the S process to exit abnormally. Let's hope that you never encounter the last possibility. The usual way to quit is to call q(), or just to come to an end-of-file on the standard input. This actually terminates the current evaluator; in the default situation you only have one evaluator, so that ends the session.

Startup:

There are a variety of ways to control what happens when the S sesson starts up. Each of these will be applied, if the relevant file or object exists, and they occur in the order presented here. See also Working Data below.If the file ".S_chapters" exists in your login directory, this is interpreted as the names of the S chapters you want loaded by default. If that file doesn't exist, the file of the same name in the SHOME directory is used; if that doesn't exist, your local version of S is likely messed up, but S goes on and assumes only library main is needed. The file should consist of names of libraries, one per line; these are the libraries S will attach to start.If the file .S.init exists in your login directory, S will treat this as a file containing S expressions, and will parse and evaluate it.S looks for a function .First in any of the databases attached at the start of the session. If it finds one it evaluates a call to that function, with no arguments.

Working Data:

When S starts a session, it sets up the working database in position 1 according to a sequence of preferred locations for chapters. In order, S tests three directories for being an S chapter: the current directory, and a subdirectory MySwork of the login directory. If none of these is an S chapter, the session is started with an empty working database unassociated with any chapter. You can change the startup working database by any of the initialization techniques above; e.g., by calling attach in your .First function.

Wrapup:

When S quits from the session, it looks for a function .Last, and evaluates a call to that function, without arguments.