-
Notifications
You must be signed in to change notification settings - Fork 104
Style Guide
Phil Burk edited this page Dec 31, 2016
·
8 revisions
This guide is a work in progress. I welcome input from other developers.
- 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.
Indentation - 4 spaces, no tabs, no trailing spaces
- 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
;