e4a838d588
FossilOrigin-Name: 03f8a1f5293ceeb245b4e6315578c114c69eb4341027fad8eba5ec8c8dbca5fa
143 lines
9 KiB
HTML
143 lines
9 KiB
HTML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml"><head>
|
|
<title>.</title>
|
|
<style type="text/css">
|
|
|
|
* { color: #000; background: #fff; max-width: 700px; }
|
|
tt, pre { background: #dedede; color: #111; font-family: monospace;
|
|
white-space: pre; display: block; width: 100%; }
|
|
.indentedcode { margin-left: 2em; margin-right: 2em; }
|
|
.codeblock {
|
|
background: #dedede; color: #111; font-family: monospace;
|
|
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
|
|
padding: 7px;
|
|
display: block;
|
|
}
|
|
|
|
.indentedlist { margin-left: 2em; color: #000; }
|
|
|
|
span { white-space: pre; }
|
|
.text { color: #000; white-space: pre; background: #dedede; }
|
|
.colon { color: #000; background: #dedede; }
|
|
.note { color: #000; background: #dedede; }
|
|
.str { color: #000; text-decoration: underline; background: #dedede; }
|
|
.num { color: #000; background: #dedede; font-weight: bold; font-style: italic; }
|
|
.fnum { color: #000; font-weight: bold; background: #dedede; }
|
|
.ptr { color: #000; font-weight: bold; background: #dedede; }
|
|
.fetch { color: #000; font-style: italic; background: #dedede; }
|
|
.store { color: #000; font-style: italic; background: #dedede; }
|
|
.char { color: #000; background: #dedede; }
|
|
.inst { color: #000; background: #dedede; }
|
|
.defer { color: #000; background: #dedede; }
|
|
.imm { color: #000; font-weight: bold; background: #dedede; }
|
|
.prim { color: #000; font-weight: bolder; background: #dedede; }
|
|
|
|
.tt { white-space: pre; font-family: monospace; background: #dedede; }
|
|
|
|
.h1, .h2, .h3, .h4 { white-space: normal; }
|
|
.h1 { font-size: 125%; }
|
|
.h2 { font-size: 120%; }
|
|
.h3 { font-size: 115%; }
|
|
.h4 { font-size: 110%; }
|
|
.hr { display: block; height: 2px; background: #000000; }
|
|
</style>
|
|
</head><body>
|
|
<p><span class="h1">Naming Conventions</span>
|
|
<br/><br/>
|
|
Word names in RETRO generally follow the following conventions.
|
|
<br/><br/>
|
|
<span class="h2">General Guidelines</span>
|
|
<br/><br/>
|
|
• Readability is important<br/>
|
|
• Be consistent<br/>
|
|
• Don't use a prefix as the first character of a name<br/>
|
|
• Don't use underscores in word names<br/>
|
|
• Use short names for indices<br/>
|
|
• Word names start with a <span class="tt">-</span> for "not"<br/>
|
|
• Words returning a flag end in ?<br/>
|
|
<br/><br/>
|
|
<span class="h2">Typical Format</span>
|
|
<br/><br/>
|
|
The word names will generally follow a form like:
|
|
<br/><br/>
|
|
<tt class='indentedcode'>[namespace:]name</tt>
|
|
<br/><br/>
|
|
The <span class="tt">namespace:</span> is optional, but recommended for consistency
|
|
with the rest of the system and to make it easier to identify
|
|
related words.
|
|
<br/><br/>
|
|
<span class="h2">Case</span>
|
|
<br/><br/>
|
|
Word names are lowercase, with a dash (-) for compound names.
|
|
<br/><br/>
|
|
<tt class='indentedcode'>hello</tt>
|
|
<tt class='indentedcode'>drop-pair</tt>
|
|
<tt class='indentedcode'>s:for-each</tt>
|
|
<br/><br/>
|
|
Variables use TitleCase, with no dash between compound names.
|
|
<br/><br/>
|
|
<tt class='indentedcode'>Base</tt>
|
|
<tt class='indentedcode'>Heap</tt>
|
|
<tt class='indentedcode'>StringBuffers</tt>
|
|
<br/><br/>
|
|
Constants are UPPERCASE, with a dash (-) for compound names.
|
|
<br/><br/>
|
|
<tt class='indentedcode'>TRUE</tt>
|
|
<tt class='indentedcode'>FALSE</tt>
|
|
<tt class='indentedcode'>f:PI</tt>
|
|
<tt class='indentedcode'>MAX-STRING-LENGTH</tt>
|
|
<br/><br/>
|
|
<span class="h2">Namespaces</span>
|
|
<br/><br/>
|
|
Words are grouped into broad namespaces by attaching a short
|
|
prefix string to the start of a name.
|
|
<br/><br/>
|
|
The common namespaces are:
|
|
<br/><br/>
|
|
<tt class='indentedcode'>| Prefix | Contains |</tt>
|
|
<tt class='indentedcode'>| ------- | ------------------------------------------------------ |</tt>
|
|
<tt class='indentedcode'>| a: | Words operating on simple arrays |</tt>
|
|
<tt class='indentedcode'>| ASCII: | ASCII character constants for control characters |</tt>
|
|
<tt class='indentedcode'>| buffer: | Words for operating on a simple linear LIFO buffer |</tt>
|
|
<tt class='indentedcode'>| c: | Words for operating on ASCII character data |</tt>
|
|
<tt class='indentedcode'>| class: | Contains class handlers for words |</tt>
|
|
<tt class='indentedcode'>| d: | Words operating on the Dictionary |</tt>
|
|
<tt class='indentedcode'>| err: | Words for handling errors |</tt>
|
|
<tt class='indentedcode'>| io: | General I/O words |</tt>
|
|
<tt class='indentedcode'>| n: | Words operating on numeric data |</tt>
|
|
<tt class='indentedcode'>| prefix: | Contains prefix handlers |</tt>
|
|
<tt class='indentedcode'>| s: | Words operating on string data |</tt>
|
|
<tt class='indentedcode'>| v: | Words operating on variables |</tt>
|
|
<tt class='indentedcode'>| file: | File I/O words |</tt>
|
|
<tt class='indentedcode'>| f: | Floating Point words |</tt>
|
|
<tt class='indentedcode'>| unix: | Unix system call words |</tt>
|
|
<br/><br/>
|
|
<span class="h2">Tips</span>
|
|
<br/><br/>
|
|
<span class="h3">Don't Start Names With Prefix Characters</span>
|
|
<br/><br/>
|
|
Avoid using a prefix as the first character of a word name. RETRO
|
|
will look for prefixes first, this will prevent direct use of
|
|
the work in question.
|
|
<br/><br/>
|
|
To find a list of prefix characters, do:
|
|
<br/><br/>
|
|
<tt class='indentedcode'>'prefix: d:words-with</tt>
|
|
<br/><br/>
|
|
<span class="h3">Don't Use Underscores</span>
|
|
<br/><br/>
|
|
Underscores in strings are replaced by spaces. This is problematic,
|
|
especially with variables. Consider:
|
|
<br/><br/>
|
|
<tt class='indentedcode'>'test_name var</tt>
|
|
<tt class='indentedcode'>#188 !test_name</tt>
|
|
<br/><br/>
|
|
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.
|
|
<br/><br/>
|
|
I personally recommend avoiding the use of underscores in any word
|
|
names.
|
|
</p>
|
|
</body></html>
|