AMT Datasouth PAL User Manual
Page 32

<<...>>
26
<<...>>
Description
Operator pair used to define a dictionary data object.
Usage
<<...>> Dict
Dict
Dictionary. Object defined by operator pair.
Comments
In other programming languages, the language would treat symbols like these as syntactical in
nature as opposed to executable. However, under PAL, the PAL interpreter executes these symbols
in the same manner as add or any other PAL operator.
The PAL interpreter executes the opening ("
<<
") and closing ("
>>
") symbols as completely
independent operators. The opening operator does nothing more than push a mark object onto the
operand stack. The closing operator instructs the PAL interpreter to build a dictionary object from
all objects on the top of the operand stack down to, but not including, the top most mark object.
After PAL removes all the objects from the stack and places them into the new dictionary, it
discards the mark object from the top of the stack.
The programmer must supply pairs of objects between the opening and closing symbols. In other
words, an even number of objects should appear between the "
<<
" and "
>>
" symbols.
The PAL interpreter uses the first object of each pair as the key under which to store the second
object within the dictionary. For example, the following sequence creates a dictionary with two
entries. Each entry consists of a key and an associated value.
<< /Key1 (data1) 12 [78 95] >>
The first dictionary entry created will contain the string (data1) under the literal name key /Key1.
The second entry created will contain the array of two numbers [78 95] under the numeric key 12.
The reader should note that PAL dictionaries may contain mixed types of keys and values. This
provides maximum flexibility for the PAL programmer. However, certain data types make for
more efficient search keys than other data types. For example, when later instructed to do so, the
PAL interpreter can locate a literal name or numeric key entry faster than an array or other type of
key.
Since the interpreter can locate a literal name faster than a string, the interpreter automatically
converts strings used as keys to literal names before storing them into the dictionary. The inter-
preter only performs this conversion for key entries within the dictionary. The interpreter does not
convert a string placed into a dictionary as a value object associated with a key object. For ex-
ample, the following two dictionary definitions will result in exactly the same dictionary once the
interpreter converts the key strings in the first definition.
<< (Key1) (data1) (Key2) /data2 >>
<< /Key1 (data1) /Key2 /data2 >>