Just as you do, the LOGO interpreter reads LOGO lines from left to right and the way it copes with complex expressions could perhaps be inferred from the way you yourself scan and flesh out skeletal diagrams of the type we have so far used. Clearly empty output/input boxes have to be filled, and one way to achieve this is to keep tracking from left to the right until some direct input provides an opportunity. But these diagrams, in themselves, enforce no overall direction on your activity. To get a better feel for how a LOGO instruction or expression is handled by the interpreter it helps to think of procedures as active robots (able to communicate in a limited way) and LOGO objects literally as words or lists written on pieces of paper. Imagine the LOGO line as a bench. It is here that the robots sit and objects are placed. The LOGO expression first last [cat dog] now looks like this:
The action moves from the left of the row to the right. (The interpreter prods the first robot to wake him up). First, knowing that he needs something to work on - viz. one (and only one) object as input - looks to his right. If he were to find an appropriate object there, he would use it immediately. But he finds another robot, last. So instead he asks last: Can you help me ? (We will normally say that first calls last.)
Last (who also needs an object to work on) is stung into action and now looks to his right to see if he can find something suitable for himself. He is more lucky and finds a two-element list [cat dog]. Taking this, he produces an output "dog which he passes back to first. (We will say that last returns "dog.)
Last then gets up and leaves the scene. First now has what he needs to complete his task and, using "dog, provides an output "d.
Of course, first is going to be very annoyed if there is no-one to return "d to!
Drawing pictures like these is not something you will normally want to do. On the other hand you will find it instructive just once to take control of and direct the benchful of LOGO robots needed to represent a relatively complex instruction such as
print first first butfirst se [dog mouse] "cat.
When you do, take the opportunity in your mind's eye to stand well back from the action so that only the gross events can be seen. You will notice that from a distance the processing seems to take place, not from left to right but from right to left. Apparently the first robot to do something and then to leave the stage is se, then butfirst and then the rightmost first and so on. Print is the very last to finish. There is some truth but also some distortion in this view. What cannot be seen from a distance is that the processing is initiated from the left to the right. It is print who starts everything going by calling and handing control to the leftmost first. But it is also true that print cannot finish until first has finished and handed control back (and of course the leftmost first cannot finish until his right neighbour has finished and so on down the line). The hidden movement is in reality pretty much like the wave you make as sit back suddenly in the bath. It goes straight down to the taps and then immediately swashes back towards you (with an output that overflows the rim if you have been too enthusiastic). The equivalent LOGO wave generated by print first first butfirst se [dog mouse] "cat moves like this:
Print calls first1 first1 calls first2 first2 calls butfirst butfirst calls se se processes its inputs and outputs to butfirst butfirst outputs to first2 first2 outputs to first1 first1 outputs to print print prints its input