next up previous contents
Next: Errors and error Up: CHAPTER.2: INTRODUCTION TO Previous: Some Pop-11 actions

Built in and user-defined procedures

Pop-11 has many different sorts of built in instructions, and new ones can be defined by the user. In Pop-11 these are called `procedures'. In some other languages (e.g. LISP) they are called `functions' rather than `procedures', but the kinds of entities referred to are the same, even if their definitions look different.

(Several lists of built in procedures are provided in the Poplog REF files, grouped roughly according to their function, or according to the kinds of datastructures they operate on.)

Some languages distinguish functions from procedures. The former are sets of instructions that take some input and return a result, like the mathematical functions addition, multiplication. The word "procedure" would then be reserved for sets of instructions that do something but do not have this mathematical property. Pop-11 acknowledges that underlying both concepts is a single unifying notion of a set of instructions that can be obeyed, and simply uses the one word "procedure" to cover all cases. (Lisp uses the one word "function" to cover all the cases.)

A procedure is defined in Pop-11 by specifying a name, and instructions to be obeyed when the name is used in an imperative. Having defined a procedure you can then later use it. In Pop-11 lots more can be done with procedures, as explained in chapter 4.

There are different ways of putting instructions together to form procedures. One common form is just a sequence of things to be done one after another. Another form is a conditional which specifies that what is to be done may depend on the result of one or more tests. Another common form is a loop in which a set of instructions is obeyed repeatedly, until some terminating condition is reached.

The ability to use `conditional instructions' is one of the things that make it possible for a computer to be intelligent, or appear to be intelligent. Conditionals provide flexibility in the use of instructions. This is because the program decides at run time which option to choose, rather than the programmer. However, the options available will normally have been anticipated by the programmer. In a language like Pop-11 that can create new programs at run time there is more scope for a conditional instruction whose options were not thought of by the programmer. (This is also true of Lisp and Prolog.)

The different forms of instructions available in Pop-11 will be illustrated and explained in this and later chapters: they are many and varied.



next up previous contents
Next: Errors and error Up: CHAPTER.2: INTRODUCTION TO Previous: Some Pop-11 actions



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