home *** CD-ROM | disk | FTP | other *** search
- Understanding LOGO
-
- Davis Foulger
- Connecticut IBM PC User's Group
-
- LOGO was developed explicitly as a
- children's teaching tool -- a
- language which would both introduce
- children to computers and provide a
- constructive environment in which
- they might learn by exploring. LOGO
- was designed as a language that would
- be easy to change and experiment
- with, and its development included
- testing with a lot of children.
- Effort was made to insure that
- children would have an easy time
- using the language.
-
- One of the results of this effort is
- LOGO's turtle. The turtle is a
- metaphor that directly reflects
- LOGO's orientation to children.
- Turtles are real, and that reality
- helps children identify with the
- language, which associates screen
- movement with the movement of the
- turtle. It also makes it fairly easy
- to teach the basics of the language
- to children that don't have access to
- computers. Indeed, beginners are
- frequently taught the basics with toy
- turtles, or making believe that they
- are turtles.
-
- Use of the turtle to take action
- (draw) on the computer forces the
- user to answer some fairly
- straightforward questions. These
- include:
-
- o Can I put the turtle somewhere?
- LOGO responds to this question
- with commands that include SETPOS
- X,Y, which puts the turtle on a
- point on the screen defined by X
- and Y; and HOME, which puts the
- turtle in the center of the
- screen. SETPOS 180,100 has the
- same effect as HOME.
-
- o Can I point the turtle in the
- direction I want it to go? LOGO
- responds to this question with
- commands that include SETHEADING
- D, which points the turtle in a
- compass direction where D is one
- of the 360 degrees on a compass
- (0 and 360 degrees are up on the
- screen); and TOWARDS X,Y, which
- points the turtle toward the
- point on the screen defined by X
- and Y. Note that both of these
- commands specify an absolute
- direction.
-
- o Can I move the turtle around?
- LOGO responds to this question
- with its FORWARD X and BACK X
- commands, which instruct a turtle
- to take X number of steps either
- FORWARD or BACK.
-
- o Can I make the turtle turn? LOGO
- responds with commands that let
- the turtle turn a given number of
- degrees (out of 360 degrees) to
- the right or left. LEFT 180 and
- RIGHT 180 both tell the turtle to
- turn around. LEFT 90 tells it to
- turn sideways to the left. Note
- that these commands specify a
- direction relative to the
- direction the turtle is pointing
- in.
-
- o Can I see where the turtle has
- been? The answer to this question
- is yes, but you don't have to see
- its trace. Indeed, you can even
- cover your tracks. The PENDOWN
- command tells the turtle to draw
- a line wherever it goes (the
- result, as you might imagine, is
- a drawing). The PENUP command
- tells it not to draw when it
- moves (the result is more
- complicated drawings. The
- PENERASE tells it to draw, but to
- use the same color as the paper
- (screen). The result of PENERASE
- can be disappearing lines.
-
- These eleven commands are all you
- need to make some pretty fancy
- drawings in LOGO, and they are fairly
- easy to remember. Children tend to
- learn them quickly. Interestingly,
- adults do too.
-
- It should be noted that these "turtle
- graphics" have been widely emulated.
- They've shown up in a number of
- programming languages and have even
- been implemented as primitives to an
- operating system. It is, in fact,
- fairly simple to implement turtle
- graphics in DOS 2.0 BASIC.
-
- With these eleven commands, it is
- fairly easy to use LOGO as a kind of
- calculator for drawings. You put the
- turtle somewhere on the screen and
- just enter commands, one at a time,
- until the drawing is finished. There
- is nothing wrong with taking this
- approach. Indeed, the fact that you
- can do it is one of LOGO's better
- features. Still, with the addition of
- one more command, we can extend the
- range of LOGO considerably.
-
- The TO xxxx END command is a command
- that lets you write your own commands
- in LOGO. If, for instance, you find
- yourself drawing a lot of squares in
- LOGO, the TO xxx END command allows
- you to define a SQUARE command that
- will draw squares for you. As an
- example:
-
- TO SQUARE
- FORWARD 10 LEFT 90
- FORWARD 10 LEFT 90
- FORWARD 10 LEFT 90
- FORWARD 10 LEFT 90
- END
-
- This sequence of commands in LOGO
- creates a command, called SQUARE,
- that draws squares that are 10 units
- long on each side. The sequence is
- really fairly simple, enclosing the
- commands that you would write to draw
- a square between the TO and END. Note
- that we really do the same thing four
- times. Writing a command that draws
- squares could save us a lot of
- typing.
-
- In some sense, the TO xxx END command
- allows you to teach your "turtle" how
- TO do something. LOGO's choice of
- commands here is typical of the
- language, which seems to always
- prefer highly descriptive and natural
- words. Note also that the result of
- building this command is really a
- mini program. In some sense, LOGO
- teaches you how to program without
- ever really making you write "a
- program". All you really do is build
- new commands out old ones.