A full description of S-Lang and its uses can be found at
http://www.s-lang.org/,
and the CIAO documents page at
http://cxc.harvard.edu/ciao/documents.html
contains several manuals on using S-Lang.
Much of the following is taken from the S-Lang documentation.
The syntax of S-Lang resembles C, with a few postcript-like features.
The language features both global and local variables, branching and looping constructs,
user-defined functions, structures, datatypes, and arrays. In addition, there is limited support
for pointer types. The concise array syntax rivals that of commercial array-based numerical
computing environments, and the dynamic nature of data-type allocation removes much
of the worry of memory management.
The language provides built-in support for string, integer (signed and unsigned long and short),
double precision floating point, and double precision complex numbers. In addition, it supports
user defined structure types, multi-dimensional array types, and associative arrays. To facilitate
the construction of sophisticated data structures such as linked lists and trees, a `reference'
type was added to the language. The reference type provides much of the same flexibility as pointers
in other languages.
The language provides standard arithmetic operations such as addition, subtraction, multiplication,
and division. It also provides support for modulo arithmetic as well as operations at the bit level,
e.g., exclusive-or. Any binary or unary operator may be extended to work with any data type.
For example, the addition operator (+) has been extended to work between string types to permit string
concatenation.
The binary and unary operators work transparently with array types. For example, if a and b are arrays,
then a + b produces an array whose elements are the result of element by element addition of a and b.
This permits one to do vector operations without explicitly looping over the array indices.
The S-Lang language supports several types of looping constructs and conditional statements.
The looping constructs include while, do...while, for, forever, loop, foreach, and _for.
The conditional statements include if, if-then-else, and !if.
User defined functions may be defined to return zero, one, or more values.
Functions that return zero values are similar to procedures in languages such as PASCAL.
The local variables of a function are always created on a stack allowing one to create recursive
functions. Parameters to a function are always passed by value and never by reference. However, the
language supports a reference data type that allows one to simulate pass by reference.
Unlike many interpreted languages, S-Lang allows functions to be dynamically loaded
(function autoloading). It also provides constructs specifically designed for error handling
and recovery as well as debugging aids (e.g., function tracebacks).
Functions and variables may be declared as private belonging to a namespace associated with the
compilation unit that defines the function or variable. The ideas behind the namespace implementation
stems from the C language and should be quite familiar to any one familiar with C.
Functions that compose the S-Lang run-time library are called intrinsics. Examples of S-Lang intrinsic
functions available to every S-Lang application include string manipulation functions such as strcat,
strchop, and strcmp. The S-Lang library also provides mathematical functions such as sin, cos, and tan;
however, not all applications enable the use of these intrinsics.
Most applications embedding the languages will also provide a set of intrinsic functions;
CIAO 3.0 provides a number of modules -
such as varmm, sherpa, isis, guide, chips, caldb, paramio, region, group, stackio, xpa, and pixlib -
which provide such functions.
The language supports C-like stdio input/output functions such as fopen, fgets, fputs, and fclose.
In addition it provides two functions, message and error, for writing to the standard output device
and standard error. The Varmm library provides a number of routines for accessing
astronomical datasets.
Since S-Lang is embedded into Sherpa and ChIPS, you can try the following commands
in eother ChIPS or Sherpa.
ISIS is written in S-Lang, so is also available to try out these examples.