|
Procedure Inputs
from Thinking About [TLC] Logo,
|
|
When we define a message that will require more than just its name when we use it, we need some way to indicate that additional information must be provided with the message. Also, we need to indicate how that additional information is to be used in the definition.
The problem we face is like that of creating a form letter that leaves spaces for the name of the victim. When it comes time to send a message we fill in all the appropriate places. For example,
Dear :victim
It has come to our attention that you, :victim, have
come into a large sum of money and that you, :victim,
would like to be relieved of the awesome responsibility
of keeping it. Please contact...
Slovenly yours,
Chicken Cacciatore
This is exactly what we need. Therefore we have called this
the Junk Mail Model of Computation. In Junk Mail Computing
we can embellish our simple to definitions with these
dot-ified names. Thus a general, universal, and all-purpose
box maker can be named box and defined as:
to box :side
repeat 4 [fd :side rt 90]
end
When it comes time to actually make a box of size 15, for
example, we will write
box 15
and the right thing will happen.
That is, the turtle will find the name box in the message dictionary and will notice that it needs a value to substitute for the victim slot :side. Fortunately for us (and the turtle) we have supplied a number (15), for if nothing is provided to fill in the slot then the definition won't make sense to the turtle. And we don't want to mess with an angry turtle.
Before going on to more exciting turtle functions we should think a bit more about Junk Mail Computing (called JMC) and how our armored friend might perform the operations. So here it is, when the turtle retreats inside its shell after receiving the message
box 10
Since box :side is defined as repeat 4 [fd :side rt 90], it it substitutes 10 for :side and replaces the problem of box 10 with
repeat 4 [fd 10 rt 90]
It busily goes to work on this problem and in short order has
flopped around the screen as expected.
This is all there is to Junk Mail Computing: