This idea may not sound strange, but in fact it does not hold in all programming languages; some, such as Fortran and C, allow program expressions or statements to have "side effects" in addition to their explicit values. Sisal is a "functional" language, and its property of "referential transparency" prevents side effects and guarantees a specific and well-defined meaning for each statement.

The principle of referential transparency derives from mathematics. In mathematical derivations, there is often much substitution of equivalent expressions for each other, in the search for the most concise or useful rendering of a truth. Coding in Sisal is very much like doing math, in its reliance on functions and substitutable expressions, and there is usually a straightforward transformation from mathematical notation to Sisal code. This will become clearer as we explore the nature of the language.

26

"hello world"

2 + 3 * 2

1.5 * 3.14159 / 2.0

These illustrate arithmetic operations on the usual sorts of numeric values, and they work just like intuition says they should. Operational precedence in Sisal is just what it is in other languages, which is to say that the value of the fourth expression above is eight, not ten. Mixing modes or operand types is not correct in Sisal. The following are not correct Sisal expressions:

5 * "good-bye"

3.14159 / 2

Two possible corrections for the first one above are

1.3 + real(26)

and two for the third one above are

3.14159 / 2.0

There is no possible correct way to multiply a character string by an integer, so the second expression above is uncorrectable.

All Sisal statements are expressions; each returns one or more values, and each can be used within any other Sisal expression. For instance, the following will look familiar:

These are, of course, merely calls to (presumably) user-defined functions, with expressions for arguments; one also presumes they each return a single numeric values and can thus be added. Such function and expression nesting can be carried on to any depth, and the result of evaluating an expression or function call can be substituted at the site of invocation without changing the resulting value. This is the principle of "referential transparency", the mathematical foundation we have alluded to. This principle is all-important, and we will refer to it often. Sisal expressions are quite flexible. For example, the following is also a legal Sisal expression:

Here, we have put parentheses in to simplify reading the statement, but they are not required. The if-statement compares the magnitudes of X and Y to determine which of two values to return. The value of the if-statement is then added to 1 to produce the value of the overall expression. The value of this entire expression cannot be determined without the values of

All this said, it remains to describe the elements that can make up Sisal expressions and then go on to the statements available to the programmer. This is available in detail in the Sisal language manual, [33]. Here we will merely give some general rules.

1) The normal alphabetic letters and numbers, along with the underscore character, can be used to make up Sisal identifiers.

Another_identifier

2) Identifiers can represent single values or function calls, and their names are significant up to 31 characters.

3) Case is not significant.

is the same name as

4) Numerical values are integers, reals, or double_reals. Integers do not contain decimal points. Reals either contain decimal points or are expressed in scientific notation, with the letter "e" denoting the exponent of ten. Double_reals must be expressed in scientific notation, and must have the letter "d" denoting the exponent. The numeric literals

1.0

1e0

1.e0

1.0e0

are all reals, and the literals

1.d0

1.0d0

are all double_reals.

5) Mixed mode arithmetic is forbidden. Explicit type casting is required. The casting operators are simply the names of the desired result types, used as functions. For example, to cast the `integer` value 10 into types `real` and `double_real`, use

To cast `reals` and `double_reals` into `integers`, there are three functions: `integer`, `trunc`, and `round`. Their operation is described in the Sisal language manual. The differences among them are in the way they treat signed operands.

6) The standard arithmetic operators `+`, `-`, `*`, and `/` are available for numeric values and expressions. The divide operator produces truncated `integer` results when applied to `integers`. Raising a number to a power is accomplished by way of the "`exp(b,e)`" function, which raises the value "`b`" to the power "`e`". The two arguments to `exp` may be any combination of numeric types. The type of the result will be the higher type of the two arguments, where `double_real` is higher than `real` which is higher than `integer`

7) The standard mathematical library functions are available in Sisal via an underlying C math library. These include trigonometric, exponential, and logarithmic functions. Variants are available for all numeric types.

8) Boolean values and expressions are possible (and common) in Sisal. The primitive Boolean elements are "`true`" and "`false`". The Boolean operators are "`&`" (and), "`|`" (or), and "`~`" (not).

9) Logical operations producing Boolean values are available in Sisal. The logical operators are

> (greater than) >= (greater than or equal to) < (less than) <= (less than or equal to) = (equal to) ~= (not equal to)10) Character and string values, expressions, and aggregates are possible in Sisal, and their correct uses are described in the Sisal language manual.

The above syntax resembles that of many modern programming languages. Other parts of Sisal syntax, such as if-statements, will also look familiar. However, the style in which such statements are combined will deviate slightly from expectations, so the next aspects of Sisal are areas in which it deviates significantly enough from more common imperative languages that they deserve sections for themselves.