Before explaining how to define procedures, we need to explain some of the building blocks - expressions and imperatives, already mentioned.
We need expressions to tell Pop-11 which objects to manipulate. Among the objects we can manipulate are numbers, words and lists.
Here are some expressions in Pop-11 which denote numbers:
3 999 999 + 5 (999 + 5) - 666Here is an imperative which contains an expression `999 + 5' and, using the so-called `print arrow', tells Pop-11 to print out what the expression denotes
999 + 5 =>That will make the computer print out:
** 1004The two asterisks `**' are produced by the command `=>', and are usually an indication that what follows was printed by the computer.
Pop-11 can refer to very large numbers. Here is the number 35 raised to the power 75 and printed out (the result being too long to fit on one line):
35 ** 75 => ** 63841535832883895351961209037631851266324737513861914558404806674 345771037686059212745703916880302131175994873046875Here is an expression denoting a list of words
[a list of five words]Here is a list of three lists of words and numbers
[ [a dog 4 5] [a big cat] [66 silly old men 99] ]If you want to refer to a list containing a single word in Pop-11 you can do it with the following sort of expression: [elephant]
This denotes a list containing the word "elephant". More precisely, it is an instruction to Pop-11 to create a list containing just the word "elephant". If you type the same thing again it will create another similar list, with the same word in it.
A program might use a list of words rather than a single word if, for example, it has to store someone's forenames, and you cannot tell in advance whether there will be only one forename, or several forenames. E.g.
[John Jones] [Mary Sue Wilkins] [Liberace]Since a list can contain arbitrarily many words, using lists will be more flexible in that case. Later we shall see many examples of the use of lists to group things together.
To sum up: an expression is a piece of Pop-11 which refers to some object. It may be an object which always exists, e.g. the number 99, or it may an object created as a result of the use of the expression, e.g. a lists of numbers. It may be a simple, or atomic object, such as a number, or it may be a structured object which has other objects as components, e.g lists, vectors, words and strings.
In order to do something to any such object it is necessary to use an imperative which tells Pop-11 to perform some action.