Copyright (C) 1993 by the Regents of the University of California
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
This is a program that is still being written. Many things are missing, including adequate documentation. This manual assumes that you already know how to program in Logo, and merely presents the details of this new implementation.
Read Computer_Science_Logo_Style, Volume_1:_ _Symbolic_Computing_ by Brian Harvey (MIT Press, 1997) for a tutorial on Logo programming with emphasis on symbolic computation.
Here are the special features of this dialect of Logo:
Source file compatible among Unix, DOS, and Mac platforms. Random-access arrays. Variable number of inputs to user-defined procedures. Mutators for list structure (dangerous). Pause on error, and other improvements to error handling. Comments and continuation lines; formatting is preserved when procedure definitions are saved or edited. Terrapin-style tokenization (e.g., [2+3] is a list with one member) but LCSI-style syntax (no special forms except TO). The best of both worlds. First-class instruction and expression templates (see APPLY). Macros.
Features not found in Berkeley Logo include robotics, music, GUIs, animation, parallelism, and multimedia. For those, buy a commercial version.
The process to start Logo depends on your operating system:
To leave Logo, enter the command bye.
Under Unix or DOS, if you include one or more filenames on the command line
when starting Logo, those files will be loaded before the interpreter starts
reading commands from your terminal. If you load a file that executes some
program that includes a
bye command, Logo will run that program and exit.
You can therefore write stand-alone programs in Logo and run them with
shell/batch scripts. To support this technique, Logo does not print its
usual welcoming and parting messages if you give file arguments to the logo
If you type your interrupt character (see table below) Logo will stop what it's doing and return to top-level, as if you did THROW "TOPLEVEL. If you type your quit character Logo will pause as if you did PAUSE.
Unix DOS/Windows Mac toplevel usually ctrl-C ctrl-Q command-. (period) pause usually ctrl-\ ctrl-W command-, (comma)
If you have an environment variable called LOGOLIB whose value is the name of a directory, then Logo will use that directory instead of the default
library. If you invoke a procedure that has not been defined, Logo first
looks for a file in the current directory named proc.lg where
proc is the
procedure name in lower case letters. If such a file exists, Logo loads
that file. If the missing procedure is still undefined, or if there is no
such file, Logo then looks in the library directory for a file named proc
.lg) and, if it exists, loads it. If neither file contains a
definition for the procedure, then Logo signals an error. Several
procedures that are primitive in most versions of Logo are included in the
default library, so if you use a different library you may want to include
some or all of the default library in it.
Names of procedures, variables, and property lists are case-insensitive. So are the special words END, TRUE, and FALSE. Case of letters is preserved in everything you type, however.
Within square brackets, words are delimited only by spaces and square brackets. [2+3] is a list containing one word. Note, however, that the Logo primitives that interpret such a list as a Logo instruction or expression (RUN, IF, etc.) reparse the list as if it had not been typed inside brackets.
After a quotation mark outside square brackets, a word is delimited by a space, a square bracket, or a parenthesis.
A word not after a quotation mark or inside square brackets is delimited by a space, a bracket, a parenthesis, or an infix operator +-*/=<>. Note that words following colons are in this category. Note that quote and colon are not delimiters.
A word consisting of a question mark followed by a number (e.g., ?37), when runparsed (i.e., where a procedure name is expected), is treated as if it were the sequence
( ? 37 )
making the number an input to the ? procedure. (See the discussion of templates, below.) This special treatment does not apply to words read as data, to words with a non-number following the question mark, or if the question mark is backslashed.
A line (an instruction line or one read by READLIST or READWORD) can be continued onto the following line if its last character is a tilde (~). READWORD preserves the tilde and the newline; READLIST does not.
An instruction line or a line read by READLIST (but not by READWORD) is automatically continued to the next line, as if ended with a tilde, if there are unmatched brackets, parentheses, braces, or vertical bars pending. However, it's an error if the continuation line contains only the word END; this is to prevent runaway procedure definitions. Lines explicitly continued with a tilde avoid this restriction.
If a line being typed interactively on the keyboard is continued, either with a tilde or automatically, Logo will display a tilde as a prompt character for the continuation line.
A semicolon begins a comment in an instruction line. Logo ignores characters from the semicolon to the end of the line. A tilde as the last character still indicates a continuation line, but not a continuation of the comment. For example, typing the instruction
print "abc;comment ~ def
will print the word abcdef. Semicolon has no special meaning in data lines read by READWORD or READLIST, but such a line can later be reparsed using RUNPARSE and then comments will be recognized.
To include an otherwise delimiting character (including semicolon or tilde) in a word, precede it with backslash (\). If the last character of a line is a backslash, then the newline character following the backslash will be part of the last word on the line, and the line continues onto the following line. To include a backslash in a word, use \\. If the combination backslash-newline is entered at the terminal, Logo will issue a backslash as a prompt character for the continuation line. All of this applies to data lines read with READWORD or READLIST as well as to instruction lines. A character entered with backslash is EQUALP to the same character without the backslash, but can be distinguished by the BACKSLASHEDP predicate. (However, BACKSLASHEDP recognizes backslashedness only on characters for which it is necessary: whitespace, parentheses, brackets, infix operators, backslash, vertical bar, tilde, quote, question mark, colon, and semicolon.)
An alternative notation to include otherwise delimiting characters in words is to enclose a group of characters in vertical bars. All characters between vertical bars are treated as if they were letters. In data read with READWORD the vertical bars are preserved in the resulting word. In data read with READLIST (or resulting from a PARSE or RUNPARSE of a word) the vertical bars do not appear explicitly; all potentially delimiting characters (including spaces, brackets, parentheses, and infix operators) appear as though entered with a backslash. Within vertical bars, backslash may still be used; the only characters that must be backslashed in this context are backslash and vertical bar themselves.
Characters entered between vertical bars are forever special, even if the word or list containing them is later reparsed with PARSE or RUNPARSE. Characters typed after a backslash are treated somewhat differently: When a quoted word containing a backslashed character is runparsed, the backslashed character loses its special quality and acts thereafter as if typed normally. This distinction is important only if you are building a Logo expression out of parts, to be RUN later, and want to use parentheses. For example,
PRINT RUN (SE "\( 2 "+ 3 "\))
will print 5, but
RUN (SE "MAKE ""|(| 2)
will create a variable whose name is open-parenthesis. (Each example would fail if vertical bars and backslashes were interchanged.)
Go to the first, previous, next, last section, table of contents.