next up previous contents
Next: Built in and Up: CHAPTER.2: INTRODUCTION TO Previous: Some Pop-11 data-types

Some Pop-11 actions

Associated with each type of data will be a collection of actions that can be applied to instances of that type. Some actions can be applied to several different types, e.g. printing.

The actions, or processes are produced by imperatives in Pop-11. Actions may create objects, compare them, search for them, store them inside other objects, print them out, etc.

There are many forms of imperatives for different purposes. For example, here is a command to calculate the sum of two numbers and print out the result:

    99 + 66 =>
which prints out

    ** 165
Here is a command to concatenate two strings and print out the result:

    'the cat sat ' >< 'on the mat' =>
which prints out

    ** the cat sat on the mat
(Pop-11 does not normally print the string quotes, but can be made to, by assigning true to the global variable pop_pr_quotes.)

Here is an imperative that declares the word "vec" to be the name of a new variable:

    vars vec;
Here is an imperative that creates a vector of four elements and assigns it to "vec";

    {a four element vector} -> vec;
Here is a command that accesses the third element of the vector and prints it out

    vec(3) =>
which prints out

    ** element
The following command updates the third element of vec with the word "item", and the next one prints out the vector vec, which has been changed:

    "item" -> vec(3);
    vec =>
which prints

    ** {a four item vector}

Assignments in Pop-11 and other languages.

An assignment is a command to store an item in a variable (or identifier). Here is an assignment of a number to a variable.

    66 -> num;
Read `->' as `goes to'. Unlike most languages, assignments in Pop-11 go from left to right: first specify the object to be assigned, then say where it is to be stored. In C this would be written as

    num = 66
In languages of the Algol family (e.g. Pascal) it would be

    num := 66
In Lisp it would be

    (setq num 66)
In some languages, e.g. Prolog, this sort of thing cannot be expressed.

In Pop-11 the assignment syntax using "->" can be used for more complex processes than updating a variable. In particular, it can also be used to invoke the "updater" of a procedure, as will be explained later.



next up previous contents
Next: Built in and Up: CHAPTER.2: INTRODUCTION TO Previous: Some Pop-11 data-types



Aaron Sloman
Fri Jan 2 03:17:44 GMT 1998