Because the Logo programming language has never been rigidly specified or standardized, each new implementation of the language tends to introduce a new dialect. Cologo is no exception. In particular, Cologo diverges from popular implementations of Logo where it benefits the grid layout and the gadget runtime environment.
Cologo is largely based on Berkeley Logo (also known as UCB Logo), an implementation of Logo by Brian Harvey and students at the University of California at Berkeley. The current version of Cologo implements a subset of Berkeley Logo, and future versions will implement more of Berkeley Logo's features as it makes sense to do so.
This section describes the differences between Cologo and other implementations of Logo, and illustrates how to convert published Logo programs to run on Cologo.
Cologo includes many features and conventions common to other Logo implementations:
"symbol. Number literals are quoted automatically. List literals are surrounded by square brackets; every term inside a list literal is a quoted word, except for nested sets of square brackets which form inner lists.
pauseinstruction in a program, and the
continueinstruction on the command line. While paused, the user can interact with the interpreter in its current state, including the inspection and manipulation of variables in the scope in which the interpreter was paused.
Cologo does not have some features found in other Logos. Some of these features have been omitted by choice or necessity. Others are planned for future releases of Cologo.
Many versions of Logo let you describe arithmetic expressions using the familiar syntax with operators between the terms, such as
3 * 4 + 5. For everything else, Logo uses a prefix syntax, with the terms following the operator:
set "x log 21
In Cologo, all operators use prefix notation:
sum product 3 4 5 This is mostly to make programs easier to read in the grid layout, where each term and operator appears in a separate cell. Early experiments indicated that infix operators in an expression such as
3 * 4 + 5 are not so convenient when spread across five cells.
Furthermore, Cologo does not use the traditional symbols for arithmetic and comparison operators. For example, instead of
/, the Cologo operators are
quotient. This accommodates readability in a grid layout, where a single cell containing punctuation may be difficult to read. This also avoids conflicts with Google Spreadsheets data entry features, where
= begins a spreadsheet formula.
Many versions of Logo support creating procedures using command-line interaction, in addition to accepting program definitions stored in files. This is a great way to experiment with Logo when only a command line is available.
In Cologo, the developer interacts with Cologo by editing the spreadsheet. Changes to the spreadsheet are recognized by the interpreter (almost) immediately, even if the program is currently running. The grid layout makes it easy to experiment with procedure definitions even with other program code on the sheet. Since interaction via the spreadsheet is the primary method for experimenting with Cologo, creating procedures on the command line is not supported.
Because Cologo runs in a web browser, it does not have access to the local file system. Berkeley Logo's file input/output features have been omitted.
Future versions of Cologo may support other kinds of input and output, such as accessing resources over the Internet, or local persistent storage via Google Gears.
Features to manipulate a text-based terminal display are not supported by Cologo. Instead, Cologo has a text console for printing messages.
Cologo currently lacks a mechanism for prompting the user for input during the run of a program, either via text prompts or via mouse interaction. These will be considered for future versions. One alternative: If the user has access to the program's spreadsheet, the user can interact with the program by editing data on the spreadsheet.
Because Cologo runs in a web browser, a program cannot run commands or open applications on the user's computer.
Berkeley Logo supports a syntax for escaping literal whitespace in quoted values, using either backslashes (
\x) or vertical bars (
|...|). Because Cologo uses cell boundaries in the grid layout to separate terms instead of space characters, this syntax is largely unnecessary, and so is not supported. For example, in Cologo, you can represent the word value
Hello there! with a single cell:
Cologo supports 4 special values inside quoted lists:
\\] inside quoted lists are equivalent to
"\] outside quoted lists, respectively. No other character escaping is currently supported.
There is a need for character escaping in Cologo, it just hasn't been implemented yet. In particular, there is no easy way to include space characters at the end of a word literal. To make data entry easier in Google Spreadsheets, Cologo ignores leading and trailing space characters in cells. As a workaround, a word containing a single space character can be calculated like this:
first " x
The command line interface splits on spaces instead of cell boundaries. It is currently not possible to enter a word containing a space using the command line interface.
Berkeley Logo has several features controllable using variables, such as
CASEIGNOREDP. These options are not implemented, and in some cases neither is their default behavior.
Some features not yet available in Cologo are obviously good features, and will probably be added in future versions of Cologo.
Cologo does not yet have arrays and property lists, as Berkeley Logo does. These useful features will be added in a future version. (They have been omitted only for expedience.)
Cologo does not yet support Berkeley Logo template-based iteration.
Cologo does not yet support Berkeley Logo macros.
Cologo does not yet support Berkeley Logo's backtick expressions for inline evaluation of code in list literals. It's not clear how to best represent this construct using the grid layout, and this feature will probably be postponed until an alternate feature is designed (and needed).
Cologo does not yet support variable-length argument lists for procedures, as Berkeley Logo does.
Cologo does support
continue. However, it does not yet support passing an argument to
continue to be output by
Cologo does not yet support
Cologo does not yet support a visible turtle.
Cologo does not yet support changing the background color.
Cologo does not yet support the drawing of arcs.
Cologo does not yet support Berkeley Logo's "scrunch" feature.
Cologo's grid layout, interaction via Google Spreadsheets, and implementation as a web gadget in a web browser are all defining features of Cologo that are not present in most other Logo implementations. There are a few additional minor differences that are worth noting.
In Berkeley Logo, a procedure is defined as follows:
to square :size repeat 4 [ fd :size rt 90 ] end
In Cologo, the syntax for procedure definition is slightly different:
to square, the procedure begins with a single cell containing the label for the procedure:
size(no colon as in Berkeley Logo). They appear in adjacent cells on the same line as the procedure label.
end, with only blank cells in between them. Instructions appear to the right of this column in the rows between the label and the
end. (In contrast, Berkeley Logo ignores whitespace when determining the structure of the program.)
In Logo, variables are dynamically scoped: A procedure can access all of the variables visible in the scope of the caller. A procedure can "hide" such a variable for the rest of its run by defining a local variable with the same name.
Cologo includes primitives that provide direct access to a "global" scope. The global scope behaves just like other scopes when accessed using
get, or variable dereferencing (such as
:varname). However, global variables are still accessible even when "hidden" by local definitions, using the
setglobal primitives. See also
A Cologo program can include data cells as well as program cells. These data cells can be accessed using the
getcell primitive, using cell locations relative either to a label, or to the upper-left corner of the visible area.
(There is not yet a way to modify cell data from within a Cologo program.)
Cologo treats all word values as Unicode strings, including procedure and variable names. Google Spreadsheets allows for entering international characters into cells, which are treated as Unicode characters internally.