Array

Array is a collection of one dimensional objects surrounded by square brackets and indexed by integers (machine integers) $0, 1, 2, \ldots$. Elements of any array may be arrays again, so we can express list structures by using arrays. An array is constructed when the sm1 encounters the right square bracket. Note that square brackets are also operators. Thus, the line
    [(Hello) 2  50  add]
sets up an array
    [(Hello)  52]
where the $0$-th element of the array is the string (Hello) and the $1$-th element is the integer 52. The put and get operator store and fetch an element of an array. The get operator takes an array and an index from the stack and returned the object indexed by the second argument. The line
   [(sm1)  12  [(is) (fun)] 15]   2    get
would return the array [(is) (fun)] on the stack. The put operator takes an array, an index i, an object from the stack and store the object at the $i$-th position of the array. That is,
 /a [(sm1) (is) (fun)] def
 a 2 (a stackmachine) put
would rewrite the contents of the variable a as
   [(sm1) (is)  (a stackmachine)]



Nobuki Takayama 2020-11-24