Getting by with no choice

Straightforward systems

So far, the procedures we have looked at have been entirely unidirectional. Remember the procedure called double.space?

to double.space
print  [ ] print [ ]
end

If you put yourself in LOGO's shoes and follow the instructions in this definition mechanically, you simply start at the beginning and proceed along a single path

print [ ] followed by print [ ]

until you come to the end. This is a route which can be diagrammed very simply:

If you prefer a more picturesque interpretation, you can think of the two rectangles in the diagram as stepping stones over which you must pass to cross from one bank of a river (START) to the other (STOP). With each hop onto a new stone there is some instruction to carry out. By pure chance, in this case, it is the same instruction on both occasions. But the important thing to notice is that at no point do you reach a fork in the crossing where, depending on the circumstances, you are obliged to make a decision to go this way as opposed to that.

If you turn to line.space, which was offered as an improvement on double space and which uses the command repeat, this procedure is at least from one point of view even simpler still. The complete body of the definition is

repeat :times [print [ ] ]

Between the header line and end - between the START and STOP banks of the stream - there is only one instruction - one stepping stone. To negotiate it, of course, it is necessary to repeat some given number of times whatever instruction list is provided as input to repeat - just as if, having jumped to the one stone in the middle of the river, you have to wait for someone to shout 'Three times. Blow your nose!' or 'Five. Hop up and down!' (and you have to do it) before jumping off to the other bank.

The procedures of Lonely Hearts are also quite simple in the same sense. Not one of them contains more that one instruction, even if the assistance of a number of other procedures may be required to carry it out. The body of lonely, for instance, consists of the single line:

op ( se someone "seeks someone why how )

Despite its length, this is just one instruction headed by one command word. The fact, that op has to call se to receive an input is irrelevant from this point of view. And it matters less still to op that se has in turn to call on someone, why and how. Op's only job is to signal to lonely that an output is ready.

Random provides no choice

Because each invocation of lonely provides a different advertisement, it is important not be deceived into thinking that there must be somewhere a choice of route in the system as a whole. There is not. The variety of advertisements generated within Lonely Hearts depends entirely on the workings of pickrandom and, from LOGO's point of view, pickrandom always works in exactly the same way. Of course, amongst other things pickrandom uses the services of the primitive random to provide it with a number. But using random is quite different from choosing to proceed this way or that. As far as LOGO is concerned, random behaves entirely consistently too. It always outputs a whole number in a given range - it just happens that what that number is cannot be known in advance.

Suppose that you always eat in the same restaurant. One lunchtime you walk into the restaurant late and find that nothing is left on the menu but a plain omelette. You accept what is on offer. By chance you are equally late the next day and everything is off but chili con carne. You take what there is and as a result you have a meal as usual - though what you eat is quite different. If you carry on like this - doing exactly the same thing - for the rest of the week, what you will eat on any particular day will be unpredictable. But the varied outcome will clearly not depend on anything you do. You will simply have no choice.

This is just how things are in the Lonely Hearts microworld. On each separate invocation of lonely, LOGO carries out the appropriate instructions in the various daughter procedures in exactly the same way and arrives every time, in one important sense, at exactly the same outcome - an adverstisement displayed on screen. It just happens that, despite taking precisely the same route, and despite its helpmates taking precisely the same route, lonely ends up by collecting for your benefit on (almost) every occasion a rather different bundle of words.

But sometimes decisions must be made. . . To see why and how, click Next page.



Ron Brasington
Department of Linguistic Science
The University of Reading
Reading
UK

E-mail: ron.brasington@rdg.ac.uk