TO procname :input1 :input2 ... (special form)
command. Prepares Logo to accept a procedure definition. The procedure
will be named procname
and there must not already be a procedure by
that name. The inputs will be called input1
etc. Any number of
inputs are allowed, including none. Names of procedures and inputs are
case-insensitive.
Unlike every other Logo procedure, TO takes as its inputs the actual words typed in the instruction line, as if they were all quoted, rather than the results of evaluating expressions to provide the inputs. (That's what "special form" means.)
This version of Logo allows variable numbers of inputs to a procedure. Every procedure has a MINIMUM, DEFAULT, and MAXIMUM number of inputs. (The latter can be infinite.)
The MINIMUM number of inputs is the number of required inputs, which must come first. A required input is indicated by the
:inputname
notation.
After all the required inputs can be zero or more optional inputs, represented by the following notation:
[:inputname default.value.expression]
When the procedure is invoked, if actual inputs are not supplied for these optional inputs, the default value expressions are evaluated to set values for the corresponding input names. The inputs are processed from left to right, so a default value expression can be based on earlier inputs. Example:
to proc :inlist [:startvalue first :inlist]
If the procedure is invoked by saying
proc [a b c]
then the variable inlist
will have the value [A B C] and the variable startvalue
will have the value A. If the procedure is invoked by saying
(proc [a b c] "x)
then inlist
will have the value [A B C] and startvalue
will have the value X.
After all the required and optional input can come a single rest
input, represented by the following notation:
[:inputname]
This is a rest input rather than an optional input because there is no default value expression. There can be at most one rest input. When the procedure is invoked, the value of this input will be a list containing all of the actual inputs provided that were not used for required or optional inputs. Example:
to proc :in1 [:in2 "foo] [:in3]
If this procedure is invoked by saying
proc "x
then in1
has the value X, in2
has the value FOO, and in3
has the value [] (the empty list). If it's invoked by saying
(proc "a "b "c "d)
then in1
has the value A, in2
has the value B, and in3
has the value [C D].
The MAXIMUM number of inputs for a procedure is infinite if a rest input is given; otherwise, it is the number of required inputs plus the number of optional inputs.
The DEFAULT number of inputs for a procedure, which is the number of inputs that it will accept if its invocation is not enclosed in parentheses, is ordinarily equal to the minimum number. If you want a different default number you can indicate that by putting the desired default number as the last thing on the TO line. example:
to proc :in1 [:in2 "foo] [:in3] 3
This procedure has a minimum of one input, a default of three inputs, and an infinite maximum.
Logo responds to the TO command by entering procedure definition mode.
The prompt character changes from ?
to >
and whatever instructions you type become part of the definition until you type a line containing
only the word END.
DEFINE procname text
command. Defines a procedure with name procname
and text text
. If
there is already a procedure with the same name, the new definition
replaces the old one. The text input must be a list whose members are
lists. The first member is a list of inputs; it looks like a TO line
but without the word TO, without the procedure name, and without the
colons before input names. In other words, the members of this first
sublist are words for the names of required inputs and lists for the
names of optional or rest inputs. The remaining sublists of the text
input make up the body of the procedure, with one sublist for each
instruction line of the body. (There is no END line in the text input.)
It is an error to redefine a primitive procedure unless the variable
REDEFP has the value TRUE.
See section redefp
TEXT procname
outputs the text of the procedure named procname
in the form expected
by DEFINE: a list of lists, the first of which describes the inputs to
the procedure and the rest of which are the lines of its body. The text
does not reflect formatting information used when the procedure was
defined, such as continuation lines and extra spaces.
FULLTEXT procname
outputs a representation of the procedure procname
in which formatting
information is preserved. If the procedure was defined with TO, EDIT,
or LOAD, then the output is a list of words. Each word represents one
entire line of the definition in the form output by READWORD, including
extra spaces and continuation lines. The last member of the output
represents the END line. If the procedure was defined with DEFINE, then
the output is a list of lists. If these lists are printed, one per
line, the result will look like a definition using TO. Note: the output
from FULLTEXT is not suitable for use as input to DEFINE!
See section to ; section edit ; section load ; section define
COPYDEF newname oldname
command. Makes newname
a procedure identical to oldname
. The
latter may be a primitive. If newname
was already defined, its
previous definition is lost. If newname
was already a primitive, the
redefinition is not permitted unless the variable REDEFP has the value
TRUE. Definitions created by COPYDEF are not saved by SAVE; primitives
are never saved, and user-defined procedures created by COPYDEF are
buried. (You are likely to be confused if you PO or POT a procedure
defined with COPYDEF because its title line will contain the old name.
This is why it's buried.)
Note: dialects of Logo differ as to the order of inputs to COPYDEF. This dialect uses "MAKE order," not "NAME order."
See section redefp ; section save ; section po ; section pot
MAKE varname value
command. Assigns the value value
to the variable named varname
,
which must be a word. Variable names are case-insensitive. If a
variable with the same name already exists, the value of that variable
is changed. If not, a new global variable is created.
NAME value varname (library procedure)
command. Same as MAKE but with the inputs in reverse order.
LOCAL varname LOCAL varnamelist (LOCAL varname1 varname2 ...)
command. Accepts as inputs one or more words, or a list of words. A variable is created for each of these words, with that word as its name. The variables are local to the currently running procedure. Logo variables follow dynamic scope rules; a variable that is local to a procedure is available to any subprocedure invoked by that procedure. The variables created by LOCAL have no initial value; they must be assigned a value (e.g., with MAKE) before the procedure attempts to read their value.
See section make
THING varname :quoted.varname
outputs the value of the variable whose name is the input. If there is more than one such variable, the innermost local variable of that name is chosen. The colon notation is an abbreviation not for THING but for the combination
thing "
so that :FOO means THING "FOO.
Note: Names of property lists are always case-insensitive. Names of individual properties are case-sensitive or case-insensitive depending on the value of CASEIGNOREDP, which is TRUE by default.
See section caseignoredp
PPROP plistname propname value
command. Adds a property to the plistname
property list with name
propname
and value value
.
GPROP plistname propname
outputs the value of the propname
property in the plistname
property
list, or the empty list if there is no such property.
REMPROP plistname propname
command. Removes the property named propname
from the property list
named plistname
.
PLIST plistname
outputs a list whose odd-numbered members are the names, and whose
even-numbered members are the values, of the properties in the property
list named plistname
. The output is a copy of the actual property
list; changing properties later will not magically change a list output
earlier by PLIST.
PROCEDUREP name PROCEDURE? name
outputs TRUE if the input is the name of a procedure.
PRIMITIVEP name PRIMITIVE? name
outputs TRUE if the input is the name of a primitive procedure (one built into Logo). Note that some of the procedures described in this document are library procedures, not primitives.
DEFINEDP name DEFINED? name
outputs TRUE if the input is the name of a user-defined procedure, including a library procedure. (However, Logo does not know about a library procedure until that procedure has been invoked.)
NAMEP name NAME? name
outputs TRUE if the input is the name of a variable.
CONTENTS
outputs a "contents list," i.e., a list of three lists containing names of defined procedures, variables, and property lists respectively. This list includes all unburied named items in the workspace.
BURIED
outputs a contents list including all buried named items in the workspace.
PROCEDURES
outputs a list of the names of all unburied user-defined procedures in the workspace. Note that this is a list of names, not a contents list. (However, procedures that require a contents list as input will accept this list.)
NAMES
outputs a contents list consisting of an empty list (indicating no procedure names) followed by a list of all unburied variable names in the workspace.
PLISTS
outputs a contents list consisting of two empty lists (indicating no procedures or variables) followed by a list of all unburied property lists in the workspace.
NAMELIST varname (library procedure) NAMELIST varnamelist
outputs a contents list consisting of an empty list followed by a list of the name or names given as input. This is useful in conjunction with workspace control procedures that require a contents list as input.
PLLIST plname (library procedure) PLLIST plnamelist
outputs a contents list consisting of two empty lists followed by a list of the name or names given as input. This is useful in conjunction with workspace control procedures that require a contents list as input.
Note: All procedures whose input is indicated as contentslist
will
accept a single word (taken as a procedure name), a list of words (taken
as names of procedures), or a list of three lists as described under the
CONTENTS command above.
See section contents
NODES
outputs a list of two numbers. The first represents the number of nodes of memory currently in use. The second shows the maximum number of nodes that have been in use at any time since the last invocation of NODES. (A node is a small block of computer memory as used by Logo. Each number uses one node. Each non-numeric word uses one node, plus some non-node memory for the characters in the word. Each array takes one node, plus some non-node memory, as well as the memory required by its elements. Each list requires one node per element, as well as the memory within the elements.) If you want to track the memory use of an algorithm, it is best if you invoke GC at the beginning of each iteration, since otherwise the maximum will include storage that is unused but not yet collected.
GC (GC anything)
command. Runs the garbage collector, reclaiming unused nodes. Logo does this when necessary anyway, but you may want to use this command to control exactly when Logo does it. In particular, the numbers output by the NODES operation will not be very meaningful unless garbage has been collected. Another reason to use GC is that a garbage collection takes a noticeable fraction of a second, and you may want to schedule collections for times before or after some time-critical animation. If invoked with an argument (of any value), GC runs a full garbage collection, including GCTWA (Garbage Collect Truly Worthless Atoms, which means that it removes from Logo's memory words that used to be procedure or variable names but aren't any more); without an argument, GC does a generational garbage collection, which means that only recently created nodes are examined. (The latter is usually good enough.)
PO contentslist
command. Prints to the write stream the definitions of all procedures, variables, and property lists named in the input contents list.
POALL (library procedure)
command. Prints all unburied definitions in the workspace. Abbreviates PO CONTENTS.
See section contents
POPS (library procedure)
command. Prints the definitions of all unburied procedures in the workspace. Abbreviates PO PROCEDURES.
See section po ; section procedures
PONS (library procedure)
command. Prints the definitions of all unburied variables in the workspace. Abbreviates PO NAMES.
See section po ; section names
POPLS (library procedure)
command. Prints the contents of all unburied property lists in the workspace. Abbreviates PO PLISTS.
See section po ; section plists
PON varname (library procedure) PON varnamelist
command. Prints the definitions of the named variable(s).
Abbreviates PO NAMELIST varname(list).
See section po ; section namelist
POPL plname (library procedure) POPL plnamelist
command. Prints the definitions of the named property list(s).
Abbreviates PO PLLIST plname(list).
See section po ; section pllist
POT contentslist
command. Prints the title lines of the named procedures and the definitions of the named variables and property lists. For property lists, the entire list is shown on one line instead of as a series of PPROP instructions as in PO.
See section pprop ; section po
POTS (library procedure)
command. Prints the title lines of all unburied procedures in the workspace. Abbreviates POT PROCEDURES.
See section procedures
ERASE contentslist ER contentslist
command. Erases from the workspace the procedures, variables, and property lists named in the input. Primitive procedures may not be erased unless the variable REDEFP has the value TRUE.
See section redefp
ERALL
command. Erases all unburied procedures, variables, and property lists from the workspace. Abbreviates ERASE CONTENTS.
See section contents
ERPS
command. Erases all unburied procedures from the workspace.
Abbreviates ERASE PROCEDURES.
See section erase ; section procedures
ERNS
command. Erases all unburied variables from the workspace. Abbreviates ERASE NAMES.
See section erase ; section names
ERPLS
command. Erases all unburied property lists from the workspace.
Abbreviates ERASE PLISTS.
See section erase ; section plists
ERN varname (library procedure) ERN varnamelist
command. Erases from the workspace the variable(s) named in the input. Abbreviates ERASE NAMELIST varname(list).
See section erase ; section namelist
ERPL plname (library procedure) ERPL plnamelist
command. Erases from the workspace the property list(s) named in the input. Abbreviates ERASE PLLIST plname(list).
See section erase ; section pllist
BURY contentslist
command. Buries the procedures, variables, and property lists named in the input. A buried item is not included in the lists output by CONTENTS, PROCEDURES, VARIABLES, and PLISTS, but is included in the list output by BURIED. By implication, buried things are not printed by POALL or saved by SAVE.
See section contents ; section procedures section pons ; section plists ; section poall ; section save
BURYALL (library procedure)
command. Abbreviates BURY CONTENTS.
See section contents
BURYNAME varname (library procedure) BURYNAME varnamelist
command. Abbreviates BURY NAMELIST varname(list).
See section bury ; section namelist
UNBURY contentslist
command. Unburies the procedures, variables, and property lists named in the input. That is, the named items will be returned to view in CONTENTS, etc.
See section contents
UNBURYALL (library procedure)
command. Abbreviates UNBURY BURIED.
See section buried
UNBURYNAME varname (library procedure) UNBURYNAME varnamelist
command. Abbreviates UNBURY NAMELIST varname(list).
See section unbury ; section namelist
TRACE contentslist
command. Marks the named items for tracing. A message is printed whenever a traced procedure is invoked, giving the actual input values, and whenever a traced procedure STOPs or OUTPUTs. A message is printed whenever a new value is assigned to a traced variable using MAKE. A message is printed whenever a new property is given to a traced property list using PPROP.
See section stop ; section output ; section make ; section pprop
UNTRACE contentslist
command. Turns off tracing for the named items.
STEP contentslist
command. Marks the named items for stepping. Whenever a stepped procedure is invoked, each instruction line in the procedure body is printed before being executed, and Logo waits for the user to type a newline at the terminal. A message is printed whenever a stepped variable name is `shadowed' because a local variable of the same name is created either as a procedure input or by the LOCAL command.
See section local
UNSTEP contentslist
command. Turns off stepping for the named items.
EDIT contentslist ED contentslist (EDIT) (ED)
command. Edits the definitions of the named items, using your favorite editor as determined by the EDITOR environment variable. If you don't have an EDITOR variable, edits the definitions using jove. If invoked without an argument, EDIT edits the same temporary file left over from a previous EDIT instruction. When you leave the editor, Logo reads the revised definitions and modifies the workspace accordingly.
If there is an environment variable called TEMP, then Logo uses its value as the directory in which to write the temporary file used for editing.
Exceptionally, the EDIT command can be used without its default input and without parentheses provided that nothing follows it on the instruction line.
EDALL (library procedure)
command. Abbreviates EDIT CONTENTS.
See section contents
EDPS (library procedure)
command. Abbreviates EDIT PROCEDURES.
See section edit ; section procedures
EDNS (library procedure)
command. Abbreviates EDIT NAMES.
See section edit ; section names
EDPLS (library procedure)
command. Abbreviates EDIT PLISTS.
See section edit ; section plists
EDN varname (library procedure) EDN varnamelist
command. Abbreviates EDIT NAMELIST varname(list).
See section edit ; section namelist
EDPL plname (library procedure) EDPL plnamelist
command. Abbreviates EDIT PLLIST plname(list).
See section edit ; section pllist
SAVE filename
command. Saves the definitions of all unburied procedures, variables, and property lists in the named file. Equivalent to
to save :filename local "oldwriter make "oldwriter writer openwrite :filename setwrite :filename poall setwrite :oldwriter close :filename end
SAVEL contentslist filename (library procedure)
command. Saves the definitions of the procedures, variables, and
property lists specified by contentslist
to the file named filename
.
LOAD filename
command. Reads instructions from the named file and executes them. The file can include procedure definitions with TO, and these are accepted even if a procedure by the same name already exists. If the file assigns a list value to a variable named STARTUP, then that list is run as an instructionlist after the file is loaded.
HELP name (HELP)
command. Prints information from the reference manual about the primitive procedure named by the input. With no input, lists all the primitives about which help is available. If there is an environment variable LOGOHELP, then its value is taken as the directory in which to look for help files, instead of the default help directory.
Exceptionally, the HELP command can be used without its default input and without parentheses provided that nothing follows it on the instruction line.
Go to the first, previous, next, last section, table of contents.