The algae
interpreter assembles your Algae statements into its own
opcodes and then executes them. When you are working interactively,
it does this one statement (or one block of statements) at a time. When
its input comes from a file, the entire file is assembled before
execution of it begins.
When algae
begins execution, it normally tries to read and
execute two startup files. The first one it tries is the file in
which it expects some of its standard functions to be defined. A
default name for this file is given when algae
is
compiled--usually it's something like
`/usr/local/lib/algae/3.3.4/algae.A'. That name can be
overridden with an environment variable called ALGAE_RC0
.
Without this file, some of algae
's standard functions will be
missing. For this reason, algae
will emit an error message and
quit if it can't find the file. (That is, unless the `-S' option
is specified on the command line.)
After algae
reads its standard functions, it looks for the file
`.algae' in your home directory and executes it if it's there. This
file's name can be overridden with the ALGAE_RC1
environment
variable. Execution of this file is inhibited by the `-s' command
line option. No startup files at all are read if the `-S' option
is given.
Algae supports command line arguments to request various actions. Arguments starting with `-' are options. Other arguments specify files to execute.
Option flags always begin with a hyphen. Algae supports both traditional single-letter options and mnemonic long option names. Long option names are indicated with `--' instead of `-'. Abbreviations for option names are allowed as long as they are unique.
Options which change Algae's behavior take effect before any files are executed. The order of the arguments is unimportant, with the following two exceptions:
Below is a list of options accepted by Algae. Both the short and long option names are indicated.
algae
's
opcodes in a form like assembly language.
algae
implementation.
algae
to execute
from the command line, rather than from a file or from standard input.
Such a script is executed after any startup files but before any other
files are executed. Any number of `-e' (or `--script')
options may be given, and the specified scripts are executed in the
order in which they appear on the command line.
algae
to use interactive mode when reading from
the standard input device "stdin". Without this option, algae
uses interactive mode only when its input appears to be from a terminal.
In interactive mode, input is parsed a line at a time and exceptions do
not cause algae
to exit.
printf
.
algae
and records
the line that is currently being executed. When algae
exits, it
records this data in the file `algae.out' in the current
directory.
Use the prof
function to read the `algae.out' file and
summarize it by file and by line number.
You may wish to use the strip
function in conjunction with
profiling. Since strip
removes the line and file information
from a function, any time spent in a call to that function gets charged
to the line from which it was called.
We've encountered several systems on which operating system bugs prevent
the execution profiler from working correctly. These include a
DECstation and a Titan, both with MIPS architectures. If you have such
a system, then algae
should have been installed with the execution
profiler disabled. In that case, you'll get an error message if you try
to use the `-p' option.
algae
to run in restricted mode. The
system
function is disabled, as are "pipes" (i.e., file names
that begin with the `!' character).
Restricted mode should be used whenever you deal with untrusted Algae
code. Without it, a malicious provider of such code could cause major
damage.
algae
normally uses it
for interactive command line editing and history. The `-r' option
forces algae
to skip Readline processing. Readline's editing
commands are similar to emacs: C-f forward, C-b backward,
C-p up, and C-n down. You can change to vi
style by
typing M-C-j.
algae
's startup files are read.
This means that many of the standard functions will be unavailable.
algae
not to read stdin by default when no
file names are given on the command line.
Any file names given on the command line are executed as input to Algae.
If no file names are given (and the -x
option is not present),
input comes from stdin. You can specify stdin explicitly with a single
hyphen, so a command line like
algae init.A -
has algae
execute `init.A' first and then read from standard
input.
Several types of errors may be encountered when running algae
.
The two most common are parse errors and run time errors.
Parse errors occur while algae
is parsing its input statements.
Run time errors occur while algae
is executing its code. In both
cases, algae
prints a file name and line number associated with
the error.
When executing interactively, algae
displays the primary prompt
when it is ready to read a command, and the secondary prompt when it
needs more input to complete a command. You can customize the prompt
simply by assigning a character vector to the global variable
$prompt
. Its first two elements specify the primary and
secondary prompts. By default, $prompt
is ( "> ", " " )
.
Assigning something other than a character vector to $prompt
is
not an error---algae
just won't give you a prompt. (Wouldn't it
be fun to accept a function? Hmm, maybe someday.)
If the GNU Readline facility is available (that is, linked with
algae
during installation), algae
normally uses it for
interactive command line editing and history. Readline's editing
commands are similar to emacs: C-f forward, C-b backward,
C-p up, and C-n down. You can change to vi
style by
typing M-C-j. The `-r' command line option forces
algae
to skip Readline processing.
If
algae
receives an interrupt signal (because you pressed a
C-c on the keyboard, for example), it stops what it's doing and
returns to the prompt. (If it isn't running interactively, it simply
exits.) On Unix systems, you can also use the kill
command to
send a signal to a process.
The implementation of interrupt signal handling in algae
is
necessarily a compromise. We want it to respond promptly, but not at
the expense of our performance. As a result, it sometimes happens that
algae
does not respond promptly to an interrupt signal. (If you
find a case like this; please report it. Sometimes it's the result of
an oversight.)
Sending
algae
a quit signal causes an immediate, clean exit.
There are various other signals which will cause algae
to
terminate, but this is the one to use if you want your files closed
properly, etc.
Go to the first, previous, next, last section, table of contents.