Skip to content
Phil Burk edited this page Dec 31, 2016 · 8 revisions

DRAFT Style Guide

This guide is a work in progress. I welcome input from other developers.

Goals

  • Consistent style for new additions. When the style is settled I may apply it to old code.
  • Consistent with older projects, specifically HMSL.
  • Improve readability.

General

Indentation - 4 spaces, no tabs, no trailing spaces

Forth

  • Use upper case for new words when they are defined.
  • Use upper case for conditional words, eg. IF ELSE THEN DO LOOP CASE ENDCASE BEGIN UNTIL WHILE REPEAT etc.
  • Use lower case for other words, eg. dup swap etc.
  • Align conditionals.
  • Forth words in comments should be upper case.
  • Constants should use underscores as separators, eg. MIDI_NUM_PORTS

For example:

: NEW.WORD ( x y -- , do something interesting without using SWAP )
    2dup =
    IF +
    ELSE *
    THEN
;

'C'

Clone this wiki locally