2019-03-18 15:52:49 +01:00
|
|
|
# Naming Conventions
|
|
|
|
|
|
|
|
Word names in RETRO generally follow the following conventions.
|
|
|
|
|
2019-03-21 14:24:15 +01:00
|
|
|
## General Guidelines
|
|
|
|
|
|
|
|
* Readability is important
|
|
|
|
* Be consistent
|
2021-03-30 13:58:25 +02:00
|
|
|
* Don't use a sigil as the first character of a name
|
2019-05-03 03:09:37 +02:00
|
|
|
* Don't use underscores in word names
|
2019-03-21 14:24:15 +01:00
|
|
|
* Use short names for indices
|
2019-05-28 15:10:00 +02:00
|
|
|
* Word names start with a `-` for "not"
|
|
|
|
* Words returning a flag end in ?
|
2019-03-21 14:24:15 +01:00
|
|
|
|
|
|
|
## Typical Format
|
|
|
|
|
|
|
|
The word names will generally follow a form like:
|
|
|
|
|
|
|
|
[namespace:]name
|
|
|
|
|
|
|
|
The `namespace:` is optional, but recommended for consistency
|
|
|
|
with the rest of the system and to make it easier to identify
|
|
|
|
related words.
|
|
|
|
|
2019-03-18 15:52:49 +01:00
|
|
|
## Case
|
|
|
|
|
|
|
|
Word names are lowercase, with a dash (-) for compound names.
|
2019-03-21 14:24:15 +01:00
|
|
|
|
2020-02-12 15:50:49 +01:00
|
|
|
hello
|
|
|
|
drop-pair
|
|
|
|
s:for-each
|
2019-03-21 14:24:15 +01:00
|
|
|
|
2019-03-18 15:52:49 +01:00
|
|
|
Variables use TitleCase, with no dash between compound names.
|
2019-03-21 14:24:15 +01:00
|
|
|
|
2020-02-12 15:50:49 +01:00
|
|
|
Base
|
|
|
|
Heap
|
|
|
|
StringBuffers
|
2019-03-21 14:24:15 +01:00
|
|
|
|
2019-03-18 15:52:49 +01:00
|
|
|
Constants are UPPERCASE, with a dash (-) for compound names.
|
|
|
|
|
2020-02-12 15:50:49 +01:00
|
|
|
TRUE
|
|
|
|
FALSE
|
|
|
|
f:PI
|
|
|
|
MAX-STRING-LENGTH
|
2019-03-21 14:24:15 +01:00
|
|
|
|
2019-03-18 15:52:49 +01:00
|
|
|
## Namespaces
|
|
|
|
|
|
|
|
Words are grouped into broad namespaces by attaching a short
|
|
|
|
prefix string to the start of a name.
|
|
|
|
|
|
|
|
The common namespaces are:
|
|
|
|
|
2020-02-12 15:50:49 +01:00
|
|
|
| Prefix | Contains |
|
|
|
|
| ------- | ------------------------------------------------------ |
|
|
|
|
| a: | Words operating on simple arrays |
|
|
|
|
| ASCII: | ASCII character constants for control characters |
|
|
|
|
| buffer: | Words for operating on a simple linear LIFO buffer |
|
|
|
|
| c: | Words for operating on ASCII character data |
|
|
|
|
| class: | Contains class handlers for words |
|
|
|
|
| d: | Words operating on the Dictionary |
|
|
|
|
| err: | Words for handling errors |
|
|
|
|
| io: | General I/O words |
|
|
|
|
| n: | Words operating on numeric data |
|
2021-03-30 13:58:25 +02:00
|
|
|
| sigil: | Contains sigil handlers |
|
2020-02-12 15:50:49 +01:00
|
|
|
| s: | Words operating on string data |
|
|
|
|
| v: | Words operating on variables |
|
|
|
|
| file: | File I/O words |
|
|
|
|
| f: | Floating Point words |
|
|
|
|
| unix: | Unix system call words |
|
2019-03-21 14:24:15 +01:00
|
|
|
|
|
|
|
## Tips
|
|
|
|
|
2021-03-30 13:58:25 +02:00
|
|
|
### Don't Start Names With Sigil Characters
|
2020-02-12 13:58:06 +01:00
|
|
|
|
2021-03-30 13:58:25 +02:00
|
|
|
Avoid using a sigil as the first character of a word name. RETRO
|
|
|
|
will look for sigils first, this will prevent direct use of
|
2019-03-21 14:24:15 +01:00
|
|
|
the work in question.
|
|
|
|
|
2021-03-30 13:58:25 +02:00
|
|
|
To find a list of sigil characters, do:
|
2019-03-21 14:24:15 +01:00
|
|
|
|
2021-03-30 13:58:25 +02:00
|
|
|
'sigil: d:words-with
|
2019-05-03 03:09:37 +02:00
|
|
|
|
2020-02-12 13:58:06 +01:00
|
|
|
### Don't Use Underscores
|
|
|
|
|
2019-05-03 03:09:37 +02:00
|
|
|
Underscores in strings are replaced by spaces. This is problematic,
|
|
|
|
especially with variables. Consider:
|
|
|
|
|
|
|
|
'test_name var
|
|
|
|
#188 !test_name
|
|
|
|
|
|
|
|
In this, the string for the name is converted to "test name". The
|
|
|
|
store in the second line will not add the space, so resolves to an
|
|
|
|
incorrect address.
|
|
|
|
|
|
|
|
I personally recommend avoiding the use of underscores in any word
|
|
|
|
names.
|