This section describes the built-in datatypes in SNOBOL5. See the DATATYPE() and DATA() functions.
STRING is a series of zero or more characters. Strings can have up through 63,999,999,952 characters in them. To limit this you will have to change the &MAXLNGTH keyword to your desired value. The original SNOBOL4 had a 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**63 through 2**63-1.
REAL is used for floating point values. The term REAL and floating point number are used interchangeably. Only double precision IEEE 754 standard 64 bit format is used. Float values can be in the range of about 1.0 * 10 ** -307 to 1.7976931348623 * 10 ** 308. Denormalized values are considered to be zero. Special values include signed zeros, signed infinities, NAN (Not a number) and denormalized numbers. On conversion to character strings, up to about 14 significant digits are displayed. On conversion from character strings to floating point, up to 18 significant digits are used. Additional significant digits won't change the value. When expressed as a character string, REAL number must start with a digit and contain a decimal point or "e" followed by an optionally signed exponent power of 10. For example, 1.23e-3 is equivalent to 0.00123. The &FLTSIG keyword can be set to the number of significant digits to display. The range is 1 to 14. If &FLTSIG is outside this range it is limited to the range. The &FLTDEC keyword controls when "e" format is used when converting a REAL to a STRING. If the first significant digit is more than &FLTDEC positions away from the decimal point, then e format is used. If &FLTDEC is set to -1, the e format is always used. However, zero is always displayed as "0.".
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 SNOBOL5 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. If the last statement in the compiled code does not branch to a known label, then the program will terminate.
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 Oregon SNOBOL5 Reference