This section describes the built-in datatypes in SNOBOL4. See the DATATYPE() and DATA() functions.
STRING
is a series of zero or more characters.
Strings can have up through 32768 characters in them.
To get strings this long, you will have to change the
&MAXLNGTH keyword to a larger value than its default of 5000.
Any other data type can be converted into a STRING using
the CONVERT() function.
ARRAY
is a one or more dimensional rectangular set of elements
indexed by integers. The values of array elements can be of any
data type.
Elements are addressed using the brackets <i1,i2...> or the
ITEM(a,i1,i2...) function.
A reference to an element outside the dimensions of the array
causes failure.
Two dimensional arrays of size N by 2 can be converted into the
TABLE data type using the CONVERT() function.
TABLE
is similar to a one dimensional array except that any data type
value can be used as an index (instead of just integers).
This makes tables much like associative arrays.
Also tables automatically grow in size as more entries are added.
Elements are addressed using the brackets <index> or the
ITEM(a,index) function.
Elements indexed by any value initially contain the null string.
Nonempty tables can be converted into N by 2 arrays using the
CONVERT() function. This is useful for accessing all of the elements
of a table in a linear manner after the table is built.
NAME
is really the address of another data item instance.
For example, if one issues the statements:
then the natural variable ABC first contains the value 'PQSV'.
'ABC' is the character form of the name of (address of) the value
'PQSV'.
The name of the variable ABC is assigned to X using the prefix dot
operator.
Then the indirect reference prefix operator $ is used to assign the
value 123 to the variable ABC.
INTEGER
holds any integer in the range of -2**31 through 2**31-1.
REAL
is used for floating point values.
Only single precision format of the Math Co-processor is used.
Float values can be in the range of about
8.43*10**-37 to 3.37*10**+38.
Special values include signed zeros, signed infinities, NAN (Not a
number) and denormalized numbers.
On conversion to character strings, 6 or 7 significant digits are
displayed. On conversion from character strings to floating point,
up to 18 significant digits are used.
If the Math Co-processor is not installed in your IBM Personal Computer,
any attempt to
perform floating point operations will give an
error message indicating that the function is undefined.
EXPRESSION
is returned when the delayed evaluation prefix operator * is
contained in an expression.
EXPRESSION values are fully evaluated during pattern matching as
they are encountered.
The following pattern, assigned to P, matches any two consecutive
characters which are the same:
A character of length 1 is assigned to the variable X during
pattern matching using the immediate value assignment operator $,
and then the expression *X is evaluated and returns the character
in variable X which must match the next position in the subject
string.
CODE
is returned by the CODE() function which compiles SNOBOL4
statements during execution.
This may be used as the target of a bracket goto <c>, which
branches to the first statement of the compiled code c.
EXTERNAL
will not occur since the LOAD function is not implemented.
PATTERN
is returned whenever a primitive pattern element or another pattern
is
concatenated in an expression or when an alternation | operator,
immediate assignment $ operator,
conditional assignment . operator,
or
a cursor position @ operator is used in an expression.
Prior Page, Next Page, First Page of the Minnesota SNOBOL4 Reference