The next sections talk in detail about each of the different variable types.
Simple types are strings or numbers that are pushed onto the operand stack when executed. Some examples are:
Table 4-2. Example Simple Types
|2||The numeric value 2.0.|
|5.6||The numeric value 5.6.|
|"string value"||The string "string value".|
|"string\nvalue"||The string "string value" with a carraige return between the 'string' and 'value' words.|
|/stringValue||The string 'stringValue'. This is equivalent to "stringValue".|
These are string values (items that start with a alpha value) which are evaluated against the dictionary stack when they are executed.
What is the dictionary stack? The Ripley interpreter starts up with two dictionary predefined. The first is the system dictionary, which contains all of the critical operands and contants values (add, mul, div, def, ripley_version, true, false, etc.) And the user dictionary which is initially empty. The dictionary stack is the set of both the user and system dictionaries. When a literal lookup occurs the user stack is checked first, then the system stack is evaluated.
Arrays are sets of variables surrounded by brackets. An example is:
Example 4-1. Array Example 1
[ 1 2 3 ]
This is an array of the values 1.0, 2.0 and 3.0.
Example 4-2. Array Example 2
[ 1 "hi" 3 ]
This is an array of the values 1.0, "hi" and 3.0.
These are just like arrays, but they are delimited with curly braces. The important difference to the Ripley system is that when they are evaluated they are pushed element by element into the execution stack. Which is then interpreter by the Ripley execution engine. This becomes very important for Functions, which we get into in the next section. Examples of Executable Arrays are in the "Making New Functions" chapter.
Dictionaries are arrays that are indexed by a unique key instead of by a ascending numeric sequence. Unlike Postscript, which has special functions to build dictionaries, you can define dictionaries using the less than and greater than symbols in Ripley. An example is:
Example 4-3. Dictionary Example
< "first_name" "Jack" "last_name" "Herrington" >
This creates a dictionary with two key value pairs. If the dictionary is accessed with "first_name" you would get "Jack" and "last_name" would get you "Herrington".