Skip to content

Instantly share code, notes, and snippets.

@crcx
Created September 12, 2010 16:34
Show Gist options
  • Save crcx/576221 to your computer and use it in GitHub Desktop.
Save crcx/576221 to your computer and use it in GitHub Desktop.

Retro Style Guide

Author: Charles Childers
Date: September 12, 2010

Formatting

  • Use ASCII (or UTF8)
  • Use 2 space indent, no tabs.
  • Use Unix-style line endings.
  • If a function is more than one line, start the code on the line following the name
  • All functions should have stack comments
  • Try not to exceed 80 characters per line
  • Avoid trailing whitespace.
  • Closing semicolons should not be on a separate line

Naming

  • use short names for indexes
  • vocabulary names should end with an apostrophe
  • constants should be in UPPERCASE
  • use camelCase with the initial word lowercase. Keep acronyms uppercase.
  • use of dotted notation (e.g., list.size) is acceptable for functions operating on a data structure

Comments

  • Comments should be enclosed in parenthesis
  • Keep comments roughly aligned within a local grouping
  • Avoid superfluous comments

Stack Comments

Stack comments in Retro are a compact form, using short codes in place of actual words. These codes are listed in the next section.

A typical comment for a word that takes two arguments and leaves one will look like:

( xy-z )

In a few cases, words may consume or leave a variable number of arguments. In this case, we denote it like:

( n-n || n- )

There are two other modifiers in use. Some words have different compile-time and run-time stack use. We prefix the comment with C: for compile-time, and R: for run-time actions.

If not specified, the stack comments are for runtime effects. Words with no C: are assumed to have no stack impact during compilation.

Codes used in the stack comments:

x, y, z, n Generic numbers
q, r Quotient, Remainder (for division)
" Word parses for a string
a Address
c ASCII character
$ Zero-terminated string
f Flag
... Variable number of values on stack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment