a collaborative web-based
programming environment

Cologo and Other Logos

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.

Similarities

Cologo includes many features and conventions common to other Logo implementations:

Features Cologo Doesn't Have

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.

No Infix Operators

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 +, -, * and /, the Cologo operators are sum, difference, product, and 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.

Create Procedures in a Spreadsheet Instead of on the Command Line

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.

No File Operations

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.

No Terminal Input or Output, No Mouse Input

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.

No Running of System Commands

Because Cologo runs in a web browser, a program cannot run commands or open applications on the user's computer.

No Ability to Seed the Random Number Generator

Cologo uses the browser's built-in functions for getting pseudo-random numbers. JavaScript (the language in which Cologo is implemented) does not offer the ability to seed the random number generator.

Character Escaping

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: "Hello there!

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.

No Switchable Features

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.

Features Cologo Doesn't Have, Yet

Some features not yet available in Cologo are obviously good features, and will probably be added in future versions of Cologo.

Arrays and Property Lists

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.)

Template-based Iteration

Cologo does not yet support Berkeley Logo template-based iteration.

Macros

Cologo does not yet support Berkeley Logo macros.

Backtick Expressions

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).

Variable Length Argument Lists

Cologo does not yet support variable-length argument lists for procedures, as Berkeley Logo does.

Continuing With a Value

Cologo does support pause and continue. However, it does not yet support passing an argument to continue to be output by pause.

Exceptions

Cologo does not yet support throw, catch or error.

Graphics Features

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.

Features Unique to Cologo

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.

Procedure Definition Syntax

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:

square:size
repeat4[
fd:size
rt90
]
end

Direct Access to Global Variables

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 set, get, or variable dereferencing (such as :varname). However, global variables are still accessible even when "hidden" by local definitions, using the getglobal and setglobal primitives. See also unsetglobal and globalvariables.

Direct Access to the Spreadsheet Contents

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.)

Unicode Support

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.