[Thread Prev] [Thread Next]
Missing (I think) from Alain's otherwise excellent explanation is the notion
that LOGO is an "extensible" language. This has to do with the relationship
between primitives and procedures.
Once a procedure has been difined (by either writing it in the Procedures Tab
or loading it from disk), it enjoys a status equal to a primitive. It is
invoked exactly the same way a primitive is invoked: by writing it's name in a
command line or in another procedure, without any special syntax such as
quotemarks or dots. It constitutes an "extension" of the language. In this
way, the user creates a unique LOGO environment, with an available vocabulary
that includes these procedures as well as the core primitives.
This is one of the most basic and most powerful of LOGO's features.
--Jeff
----- Original Message -----
From: Alain Tougas
To: mwforum@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Sent: Friday, March 23, 2007 6:21 AM
Subject: RE: [MWForum] logo vocab/primitives
Hello,
I'll try to sum it up:
Logo is a language. Like any language, it has a vocabulary and a syntax. The
vocabulary is made of primitives. So primitives are the main constituents of
the Logo vocabulary. The other constituents are the procedures that you define
Procedures are list of instructions that you group under a name (to square .
end). Primitives are "always there", procedures are there if you define them.
There are two types of primitives: the commands and the reporters. Commands
and reporters can require one or more inputs, or none. Commands execute an
action, reporters report a value. When you use a reporter, you have to make
sure that some other logo word (primitive or procedure) that will "catch"
what's being reported by the reporter.
Examples:
st (show turle) is a primitive (command) that requires no input
print is a primitive that requires one input
square is a procedure that is present, if you define it:
to square
repeat 4 [fd 50 rt 90]
end
square2 is a procedure that is present if you define it. It needs an input
to square2 :size
repeat 4 [fd :size rt 90]
end
heading is a primitive (reporter).It requires no input, but as a reporter,
it "throws" a value, that must be caught by another logo word. If you type
just "heading" in the command center, you will get an error message
I don't know what to do with 0 (or whatever number)
Here's an example of some other logo word "catching" the number thrown by
"heading"
seth heading + 45
heading reports a number (0 in this example). The plus sign wants two
inputs, one before the sign, one after. The one after is 45. For the one
"before", the plus sign "catches" the number offered by the reporter heading
(0). The plus sign adds the two (0 + 45) and itself is a reporter. It throws
the result (45) hoping that someone will catch it. The primitive (command)
seth (setheading) needs an input, it will be happy to "use" the value thrown
in the air by the plus sign.
Bottom line, the first word of a long instruction MUST be a command
(primitive or procedure).
See MicroWorlds's help, section "Programming"
Good reading,
Alain
-----Original Message-----
From: mwforum-admin@xxxxxxxxxxxxxxxxxxxxxxxxxxxx [mailto:mwforum-admin@xxxxxxxxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Tamara Weinstein
Sent: March 23, 2007 8:25 AM
To: mwforum@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Subject: [MWForum] logo vocab/primitives
I have a really basic question.
What is the difference between a primitive and logo vocabulary?
Thanks
Tamara Weinstein
Atlanta, GA
Previous by thread:
RE: logo vocab/primitives
Next by thread:
Re: logo vocab/primitives
To save an attachment to your computer, PC users should right-click (Mac users, click and hold the mouse button) on the link and then choose 'save target as' from the pop-up menu. A window will then pop up in which you can choose a location for the file.
|