]> gitweb.factorcode.org Git - factor.git/blob - core/handbook/conventions.facts
more sql changes
[factor.git] / core / handbook / conventions.facts
1 USING: arrays gadgets hashtables help io kernel-internals
2 namespaces sequences ;
3
4 ARTICLE: "conventions" "Conventions"
5 "Various conventions are used throughout the Factor documentation and source code."
6 { $heading "Word naming conventions" }
7 "These conventions are not hard and fast, but are usually a good first step in understanding a word's behavior:"
8 { $table
9     { "General form" "Description" "Examples" }
10     { { $snippet { $emphasis "foo" } "?" } "outputs a boolean" { { $link empty? } } }
11     { { $snippet "?" { $emphasis "foo" } } { "conditionally performs " { $snippet { $emphasis "foo" } } } { { $links ?nth ?hash } } }
12     { { $snippet "<" { $emphasis "foo" } ">" } { "creates a new " { $snippet "foo" } } { { $link <array> } } }
13     { { $snippet { $emphasis "foo" } "*" } { "alternative form of " { $snippet "foo" } ", or a generic word called by " { $snippet "foo" } } { { $links hash* draw-gadget* } } }
14     { { $snippet "(" { $emphasis "foo" } ")" } { "implementation detail word used by " { $snippet "foo" } } { { $link (clone) } } }
15     { { $snippet "n" { $emphasis "foo" } } { "(sequence words only) performs " { $snippet "foo" } " but modifies an input sequence instead of creating a new sequence" } { { $links nappend nsort } } }
16     { { $snippet "set-" { $emphasis "foo" } } { "sets " { $snippet "foo" } " to a new value" } { $links set-length } }
17     { { $snippet { $emphasis "foo" } "-" { $emphasis "bar" } } { "(tuple accessors) outputs the value of the " { $snippet "bar" } " slot of the " { $snippet "foo" } " at the top of the stack" } { } }
18     { { $snippet "set-" { $emphasis "foo" } "-" { $emphasis "bar" } } { "(tuple mutators) sets the value of the " { $snippet "bar" } " slot of the " { $snippet "foo" } " at the top of the stack" } { } }
19     { { $snippet "with-" { $emphasis "foo" } } { "performs some kind of initialization and cleanup related to " { $snippet "foo" } ", usually in a new dynamic scope" } { $links with-scope with-stream } }
20     { { $snippet "$" { $emphasis "foo" } } { "help markup" } { $links $heading $emphasis } }
21 }
22 { $heading "Vocabulary naming conventions" }
23 "A vocabulary name ending in " { $snippet "-internals" } " contains words which are either implementation detail, unsafe, or both. For example, the " { $snippet "sequence-internals" } " vocabulary contains words which access sequence elements without bounds checking (" { $link "sequences-unsafe" } ")."
24 $terpri
25 "You should should avoid using internal words from the Factor library unless absolutely necessary. Similarly, your own code can place words in internal vocabularies if you do not want other people to use them unless they have a good reason." ;