factor/extra/help/handbook/handbook.factor

280 lines
12 KiB
Factor
Raw Normal View History

2008-02-15 19:07:10 -05:00
USING: help help.markup help.syntax help.definitions help.topics
namespaces words sequences classes assocs vocabs kernel arrays
prettyprint.backend kernel.private io generic math system
strings sbufs vectors byte-arrays bit-arrays float-arrays
2008-03-05 20:12:40 -05:00
quotations io.streams.byte-array io.encodings.string ;
2007-09-20 18:09:08 -04:00
IN: help.handbook
ARTICLE: "conventions" "Conventions"
"Various conventions are used throughout the Factor documentation and source code."
{ $heading "Documentation conventions" }
"Factor documentation consists of two distinct bodies of text. There is a hierarchy of articles, much like this one, and there is word documentation. Help articles reference word documentation, and vice versa, but not every documented word is referenced from some help article."
$nl
"Every article has links to parent articles at the top. These can be persued if the article is too specific."
$nl
"Some generic words have " { $strong "Description" } " headings, and others have " { $strong "Contract" } " headings. A distinction is made between words which are not intended to be extended with user-defined methods, and those that are."
{ $heading "Vocabulary naming conventions" }
"A vocabulary name ending in " { $snippet ".private" } " contains words which are either implementation detail, unsafe, or both. For example, the " { $snippet "sequence.private" } " vocabulary contains words which access sequence elements without bounds checking (" { $link "sequences-unsafe" } ")."
$nl
"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."
{ $heading "Word naming conventions" }
"These conventions are not hard and fast, but are usually a good first step in understanding a word's behavior:"
{ $table
{ "General form" "Description" "Examples" }
{ { $snippet { $emphasis "foo" } "?" } "outputs a boolean" { { $link empty? } } }
{ { $snippet "?" { $emphasis "foo" } } { "conditionally performs " { $snippet { $emphasis "foo" } } } { { $links ?nth } } }
{ { $snippet "<" { $emphasis "foo" } ">" } { "creates a new " { $snippet "foo" } } { { $link <array> } } }
{ { $snippet { $emphasis "foo" } "*" } { "alternative form of " { $snippet "foo" } ", or a generic word called by " { $snippet "foo" } } { { $links at* pprint* } } }
{ { $snippet "(" { $emphasis "foo" } ")" } { "implementation detail word used by " { $snippet "foo" } } { { $link (clone) } } }
{ { $snippet "set-" { $emphasis "foo" } } { "sets " { $snippet "foo" } " to a new value" } { $links set-length } }
{ { $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" } { } }
{ { $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" } { } }
{ { $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 } }
{ { $snippet "$" { $emphasis "foo" } } { "help markup" } { $links $heading $emphasis } }
}
2008-02-06 13:09:42 -05:00
{ $heading "Stack effect conventions" }
"Stack effect conventions are documented in " { $link "effect-declaration" } "."
2007-09-20 18:09:08 -04:00
{ $heading "Glossary of terms" }
"Common terminology and abbreviations used throughout Factor and its documentation:"
{ $table
{ "Term" "Definition" }
{ "alist" { "an association list. See " { $link "alists" } } }
{ "assoc" "an associative mapping" }
{ "associative mapping" { "an object whose class implements the " { $link "assocs-protocol" } } }
{ "boolean" { { $link t } " or " { $link f } } }
{ "class" { "a set of objects identified by a " { $emphasis "class word" } " together with a discriminating predicate. See " { $link "classes" } } }
{ "definition specifier" { "a " { $link word } ", " { $link method-spec } ", " { $link link } ", vocabulary specifier, or any other object whose class implements the " { $link "definition-protocol" } } }
{ "generalized boolean" { "an object interpreted as a boolean; a value of " { $link f } " denotes false and anything else denotes true" } }
{ "generic word" { "a word whose behavior depends can be specialized on the class of one of its inputs. See " { $link "generic" } } }
{ "method" { "a specialized behavior of a generic word on a class. See " { $link "generic" } } }
{ "object" { "any datum which can be identified" } }
{ "pathname string" { "an OS-specific pathname which identifies a file" } }
{ "sequence" { "an object whose class implements the " { $link "sequence-protocol" } } }
{ "slot" { "a component of an object which can store a value" } }
2007-11-21 19:21:02 -05:00
{ "stack effect" { "a pictorial representation of a word's inputs and outputs, for example " { $snippet "+ ( x y -- z )" } ". See " { $link "effects" } } }
2007-09-20 18:09:08 -04:00
{ "true value" { "any object not equal to " { $link f } } }
{ "vocabulary" { "a named set of words. See " { $link "vocabularies" } } }
{ "vocabulary specifier" { "a " { $link vocab } ", " { $link vocab-link } " or a string naming a vocabulary" } }
{ "word" { "the basic unit of code, analogous to a function or procedure in other programming languages. See " { $link "words" } } }
} ;
ARTICLE: "evaluator" "Evaluation semantics"
{ $link "quotations" } " are evaluated sequentially from beginning to end. When the end is reached, the quotation returns to its caller. As each object in the quotation is evaluated in turn, an action is taken based on its type:"
{ $list
2008-01-02 19:36:36 -05:00
{ "a " { $link word } " - the word's definition quotation is called. See " { $link "words" } }
2007-09-20 18:09:08 -04:00
{ "a " { $link wrapper } " - the wrapped object is pushed on the data stack. Wrappers are used to push word objects directly on the stack when they would otherwise execute. See the " { $link POSTPONE: \ } " parsing word." }
{ "All other types of objects are pushed on the data stack." }
}
"If the last action performed is the execution of a word, the current quotation is not saved on the call stack; this is known as " { $snippet "tail-recursion" } " and allows iterative algorithms to execute without incurring unbounded call stack usage."
2008-02-21 00:13:31 -05:00
{ $see-also "compiler" } ;
2007-09-20 18:09:08 -04:00
ARTICLE: "dataflow" "Data and control flow"
{ $subsection "evaluator" }
{ $subsection "words" }
2007-11-21 19:21:02 -05:00
{ $subsection "effects" }
2007-09-20 18:09:08 -04:00
{ $subsection "shuffle-words" }
{ $subsection "booleans" }
{ $subsection "conditionals" }
{ $subsection "basic-combinators" }
{ $subsection "combinators" }
{ $subsection "continuations" } ;
USING: concurrency.combinators
concurrency.messaging
concurrency.promises
concurrency.futures
concurrency.locks
concurrency.semaphores
concurrency.count-downs
2008-02-25 22:33:07 -05:00
concurrency.exchangers
concurrency.flags ;
ARTICLE: "concurrency" "Concurrency"
"Factor supports a variety of concurrency abstractions, however they are mostly used to multiplex input/output operations since the thread scheduling is co-operative and only one CPU is used at a time."
$nl
"Factor's concurrency support was insipired by Erlang, Termite, Scheme48 and Java's " { $snippet "java.util.concurrent" } " library."
$nl
"The basic building blocks:"
{ $subsection "threads" }
"High-level abstractions:"
{ $subsection "concurrency.combinators" }
{ $subsection "concurrency.promises" }
{ $subsection "concurrency.futures" }
{ $subsection "concurrency.mailboxes" }
{ $subsection "concurrency.messaging" }
"Shared-state abstractions:"
{ $subsection "concurrency.locks" }
{ $subsection "concurrency.semaphores" }
{ $subsection "concurrency.count-downs" }
2008-02-19 12:37:02 -05:00
{ $subsection "concurrency.exchangers" }
2008-02-25 22:33:07 -05:00
{ $subsection "concurrency.flags" }
2008-02-19 12:37:02 -05:00
"Other concurrency abstractions include " { $vocab-link "concurrency.distributed" } " and " { $vocab-link "channels" } "." ;
2007-09-20 18:09:08 -04:00
ARTICLE: "objects" "Objects"
"An " { $emphasis "object" } " is any datum which may be identified. All values are objects in Factor. Each object carries type information, and types are checked at runtime; Factor is dynamically typed."
{ $subsection "equality" }
{ $subsection "classes" }
{ $subsection "tuples" }
{ $subsection "generic" }
2008-03-12 02:54:29 -04:00
{ $subsection "slots" }
2007-09-20 18:09:08 -04:00
{ $subsection "mirrors" } ;
USE: random
ARTICLE: "numbers" "Numbers"
{ $subsection "arithmetic" }
{ $subsection "math-constants" }
{ $subsection "math-functions" }
{ $subsection "number-strings" }
{ $subsection "random-numbers" }
"Number implementations:"
{ $subsection "integers" }
{ $subsection "rationals" }
{ $subsection "floats" }
{ $subsection "complex-numbers" }
"Advanced features:"
{ $subsection "math-vectors" }
{ $subsection "math-intervals" }
{ $subsection "math-bitfields" } ;
USE: io.buffers
ARTICLE: "collections" "Collections"
{ $heading "Sequences" }
{ $subsection "sequences" }
2008-01-30 00:17:22 -05:00
"Fixed-length sequences:"
2007-09-20 18:09:08 -04:00
{ $subsection "arrays" }
2008-01-30 00:17:22 -05:00
{ $subsection "quotations" }
"Fixed-length specialized sequences:"
{ $subsection "strings" }
2007-09-20 18:09:08 -04:00
{ $subsection "bit-arrays" }
{ $subsection "byte-arrays" }
{ $subsection "float-arrays" }
2008-01-30 00:17:22 -05:00
"Resizable sequence:"
{ $subsection "vectors" }
"Resizable specialized sequences:"
2007-09-20 18:09:08 -04:00
{ $subsection "sbufs" }
2008-01-30 00:17:22 -05:00
{ $subsection "bit-vectors" }
{ $subsection "byte-vectors" }
{ $subsection "float-vectors" }
2007-09-20 18:09:08 -04:00
{ $heading "Associative mappings" }
{ $subsection "assocs" }
{ $subsection "namespaces" }
"Implementations:"
{ $subsection "hashtables" }
{ $subsection "alists" }
{ $heading "Other collections" }
{ $subsection "boxes" }
2007-11-05 03:26:16 -05:00
{ $subsection "dlists" }
{ $subsection "heaps" }
{ $subsection "graphs" }
{ $subsection "buffers" } ;
2007-09-20 18:09:08 -04:00
USING: io.sockets io.launcher io.mmap io.monitors ;
2007-09-20 18:09:08 -04:00
2008-02-27 15:59:15 -05:00
ARTICLE: "io" "Input and output"
{ $heading "Streams" }
2007-09-20 18:09:08 -04:00
{ $subsection "streams" }
"Wrapper streams:"
2007-09-20 18:09:08 -04:00
{ $subsection "io.streams.duplex" }
{ $subsection "io.streams.plain" }
{ $subsection "io.streams.string" }
{ $subsection "io.streams.byte-array" }
2008-02-27 15:59:15 -05:00
"Utilities:"
2007-09-20 18:09:08 -04:00
{ $subsection "stream-binary" }
{ $subsection "styles" }
2008-02-27 15:59:15 -05:00
{ $heading "Files" }
{ $subsection "io.files" }
{ $subsection "io.mmap" }
2008-02-09 23:28:22 -05:00
{ $subsection "io.monitors" }
2008-03-05 20:12:40 -05:00
{ $heading "Encodings" }
{ $subsection "io.encodings" }
2008-03-05 20:12:40 -05:00
{ $subsection "io.encodings.string" }
{ $heading "Other features" }
2008-02-27 15:59:15 -05:00
{ $subsection "network-streams" }
{ $subsection "io.launcher" }
2008-02-09 23:28:22 -05:00
{ $subsection "io.timeouts" } ;
2007-09-20 18:09:08 -04:00
ARTICLE: "tools" "Developer tools"
"Exploratory tools:"
2007-09-20 18:09:08 -04:00
{ $subsection "editor" }
{ $subsection "tools.crossref" }
2007-09-20 18:09:08 -04:00
{ $subsection "inspector" }
"Debugging tools:"
{ $subsection "tools.annotations" }
{ $subsection "tools.test" }
2008-02-27 20:24:50 -05:00
{ $subsection "tools.threads" }
"Performance tools:"
2007-09-20 18:09:08 -04:00
{ $subsection "tools.memory" }
{ $subsection "profiling" }
{ $subsection "timing" }
{ $subsection "tools.disassembler" }
"Deployment tools:"
2007-09-20 18:09:08 -04:00
{ $subsection "tools.deploy" } ;
ARTICLE: "article-index" "Article index"
{ $index [ articles get keys ] } ;
ARTICLE: "primitive-index" "Primitive index"
{ $index [ all-words [ primitive? ] subset ] } ;
ARTICLE: "error-index" "Error index"
{ $index [ all-errors ] } ;
ARTICLE: "type-index" "Type index"
{ $index [ builtins get [ ] subset ] } ;
ARTICLE: "class-index" "Class index"
{ $index [ classes ] } ;
ARTICLE: "program-org" "Program organization"
{ $subsection "definitions" }
{ $subsection "vocabularies" }
{ $subsection "parser" }
{ $subsection "vocabs.loader" } ;
2008-01-11 03:32:25 -05:00
USING: help.cookbook help.tutorial ;
2007-09-20 18:09:08 -04:00
ARTICLE: "handbook" "Factor documentation"
2008-03-12 02:54:29 -04:00
"Welcome to Factor."
2007-09-20 18:09:08 -04:00
{ $heading "Starting points" }
{ $subsection "cookbook" }
2008-01-11 03:32:25 -05:00
{ $subsection "first-program" }
2007-09-20 18:09:08 -04:00
{ $subsection "vocab-index" }
{ $heading "Language reference" }
{ $subsection "conventions" }
{ $subsection "syntax" }
{ $subsection "dataflow" }
{ $subsection "objects" }
{ $subsection "program-org" }
{ $heading "Library reference" }
{ $subsection "numbers" }
{ $subsection "collections" }
{ $subsection "io" }
{ $subsection "concurrency" }
2007-09-20 18:09:08 -04:00
{ $subsection "os" }
{ $subsection "alien" }
{ $heading "Environment reference" }
2008-01-11 03:32:25 -05:00
{ $subsection "cli" }
{ $subsection "images" }
2007-09-20 18:09:08 -04:00
{ $subsection "prettyprint" }
{ $subsection "tools" }
{ $subsection "help" }
{ $subsection "inference" }
{ $subsection "compiler" }
2008-03-12 02:54:29 -04:00
{ $subsection "layouts" }
2007-09-20 18:09:08 -04:00
{ $heading "User interface" }
{ $about "ui" }
{ $about "ui.tools" }
{ $heading "Index" }
{ $subsection "primitive-index" }
{ $subsection "error-index" }
{ $subsection "type-index" }
{ $subsection "class-index" } ;
2008-01-05 17:27:15 -05:00
{ <array> <string> <sbuf> <vector> <byte-array> <bit-array> <float-array> }
related-words
{ >array >quotation >string >sbuf >vector >byte-array >bit-array >float-array }
related-words