diff --git a/basis/eval/eval-docs.factor b/basis/eval/eval-docs.factor index 2021a2d10d..f3ee35d91c 100644 --- a/basis/eval/eval-docs.factor +++ b/basis/eval/eval-docs.factor @@ -37,7 +37,7 @@ ARTICLE: "eval-vocabs" "Evaluating strings with a different vocabulary search pa (eval) with-file-vocabs } -"Code in the listener tool starts out with a different initial search path, with more vocabularies are available by default. Strings of code can be evaluated in this search path by using " { $link (eval) } " with a different combinator:" +"Code in the listener tool starts out with a different initial search path, with more vocabularies available by default. Strings of code can be evaluated in this search path by using " { $link (eval) } " with a different combinator:" { $subsections with-interactive-vocabs } diff --git a/basis/locals/locals-docs.factor b/basis/locals/locals-docs.factor index d78905c0d7..69a7ef25f6 100644 --- a/basis/locals/locals-docs.factor +++ b/basis/locals/locals-docs.factor @@ -14,9 +14,9 @@ HELP: [let HELP: :> { $syntax ":> var" ":> var!" ":> ( var-1 var-2 ... )" } -{ $description "Binds one or more new lexical variables. In the " { $snippet ":> var" } " form, the value on the top of the datastack to a new lexical variable named " { $snippet "var" } " and scoped to the enclosing quotation, " { $link POSTPONE: [let } " form, or " { $link POSTPONE: :: } " definition." +{ $description "Binds one or more new lexical variables. In the " { $snippet ":> var" } " form, the value on the top of the datastack is bound to a new lexical variable named " { $snippet "var" } " and is scoped to the enclosing quotation, " { $link POSTPONE: [let } " form, or " { $link POSTPONE: :: } " definition." $nl -"The " { $snippet ":> ( var-1 ... )" } " form binds multiple variables to the top values off the datastack in left to right order. These two snippets have the same effect:" +"The " { $snippet ":> ( var-1 ... )" } " form binds multiple variables to the top values of the datastack in right to left order, with the last variable bound to the top of the datastack. These two snippets have the same effect:" { $code ":> c :> b :> a" } { $code ":> ( a b c )" } $nl @@ -112,7 +112,7 @@ $nl $nl { $heading "Mutable bindings" } -"This next example demonstrates closures and mutable variable bindings. The " { $snippet "make-counter" } " word outputs a tuple containing a pair of quotations that respectively increment and decrement an internal counter in the mutable " { $snippet "value" } " variable and then return the new value. The quotations close over the counter, so each invocation of the word gives new quotations with a new internal counter." +"This next example demonstrates closures and mutable variable bindings. The " { $snippet "" } " word outputs a tuple containing a pair of quotations that respectively increment and decrement an internal counter in the mutable " { $snippet "value" } " variable and then return the new value. The quotations close over the counter, so each invocation of the word gives new quotations with a new internal counter." { $example """USING: locals kernel math ; IN: scratchpad diff --git a/basis/stack-checker/stack-checker-docs.factor b/basis/stack-checker/stack-checker-docs.factor index eb25b9be57..5ba70ed181 100644 --- a/basis/stack-checker/stack-checker-docs.factor +++ b/basis/stack-checker/stack-checker-docs.factor @@ -40,7 +40,7 @@ ARTICLE: "inference-combinators" "Combinator stack effects" "The following code now passes the stack checker; it would fail were " { $snippet "twice" } " not declared " { $link POSTPONE: inline } ":" { $unchecked-example "USE: math.functions" "[ [ sqrt ] twice ] infer." "( x -- x )" } { $subheading "Defining a combinator for unknown quotations" } -"In the next example, " { $link POSTPONE: call( } " must be used because the quotation the result of calling a runtime accessor, and the compiler cannot make any static assumptions about this quotation at all:" +"In the next example, " { $link POSTPONE: call( } " must be used because the quotation is the result of calling a runtime accessor, and the compiler cannot make any static assumptions about this quotation at all:" { $code "TUPLE: action name quot ;" ": perform ( value action -- result ) quot>> call( value -- result ) ;" diff --git a/basis/stack-checker/transforms/transforms-docs.factor b/basis/stack-checker/transforms/transforms-docs.factor index de0edc4528..c6675ba6d4 100644 --- a/basis/stack-checker/transforms/transforms-docs.factor +++ b/basis/stack-checker/transforms/transforms-docs.factor @@ -3,8 +3,7 @@ USING: help.markup help.syntax combinators words kernel ; HELP: define-transform { $values { "word" word } { "quot" "a quotation taking " { $snippet "n" } " inputs from the stack and producing another quotation as output" } { "n" "a non-negative integer" } } -{ $description "Defines a compiler transform for the optimizing compiler." - "When a call to " { $snippet "word" } " is being compiled, the compiler first checks that the top " { $snippet "n" } " stack values are literal, and if so, calls the quotation with those inputs at compile time. The quotation can output a new quotation, or " { $link f } "." +{ $description "Defines a compiler transform for the optimizing compiler. When a call to " { $snippet "word" } " is being compiled, the compiler first checks that the top " { $snippet "n" } " stack values are literal, and if so, calls the quotation with those inputs at compile time. The quotation can output a new quotation, or " { $link f } "." $nl "If the quotation outputs " { $link f } ", or if not all inputs are literal, a call to the word is compiled as usual, or compilation fails if the word does not have a static stack effect." $nl diff --git a/core/assocs/assocs-docs.factor b/core/assocs/assocs-docs.factor index 5a69df8cb4..34535f1a02 100644 --- a/core/assocs/assocs-docs.factor +++ b/core/assocs/assocs-docs.factor @@ -80,7 +80,7 @@ ARTICLE: "assocs-lookup" "Lookup and querying of assocs" { $see-also at* assoc-size } ; ARTICLE: "assocs-values" "Transposed assoc operations" -"default Most assoc words take a key and find the corresponding value. The following words take a value and find the corresponding key:" +"Most assoc words take a key and find the corresponding value. The following words take a value and find the corresponding key:" { $subsections value-at value-at* diff --git a/core/classes/tuple/tuple-docs.factor b/core/classes/tuple/tuple-docs.factor index e57b3deafc..2b3e80da1d 100644 --- a/core/classes/tuple/tuple-docs.factor +++ b/core/classes/tuple/tuple-docs.factor @@ -171,13 +171,13 @@ $nl } "The " { $vocab-link "delegate" } " library provides a language abstraction for expressing has-a relationships." { $heading "Anti-pattern #2: subclassing for implementation sharing only" } -"Tuple subclassing purely for sharing implementations of methods is not a good idea either. If a class " { $snippet "A" } " is a subclass of a class " { $snippet "B" } ", then instances of " { $snippet "A" } " should be usable anywhere that an instance of " { $snippet "B" } " is. If this properly does not hold, then subclassing should not be used." +"Tuple subclassing purely for sharing implementations of methods is not a good idea either. If a class " { $snippet "A" } " is a subclass of a class " { $snippet "B" } ", then instances of " { $snippet "A" } " should be usable anywhere that an instance of " { $snippet "B" } " is. If this property does not hold, then subclassing should not be used." $nl "There are two alternatives which are preferred to subclassing in this case. The first is " { $link "mixins" } "." $nl "The second is to use ad-hoc slot polymorphism. If two classes define a slot with the same name, then code which uses " { $link "accessors" } " can operate on instances of both objects, assuming the values stored in that slot implement a common protocol. This allows code to be shared without creating contrieved relationships between classes." { $heading "Anti-pattern #3: subclassing to override a method definition" } -"While method overriding is a very powerful tool, improper use can cause tight coupling of code and lead to difficulty in testing and refactoring. Subclassing should not be used as a means of “monkey patching” methods to fix bugs and add features. Only subclass from classes which were designed to be inherited from, and when writing classes of your own which are intended to be subclassed, clearly document that subclasses may and may not do. This includes construction policy; document whether subclasses should use " { $link new } ", " { $link boa } ", or a custom parametrized constructor." +"While method overriding is a very powerful tool, improper use can cause tight coupling of code and lead to difficulty in testing and refactoring. Subclassing should not be used as a means of “monkey patching” methods to fix bugs and add features. Only subclass from classes which were designed to be inherited from, and when writing classes of your own which are intended to be subclassed, clearly document what subclasses may and may not do. This includes construction policy; document whether subclasses should use " { $link new } ", " { $link boa } ", or a custom parametrized constructor." { $see-also "parametrized-constructors" } ; ARTICLE: "tuple-subclassing" "Tuple subclassing" @@ -425,7 +425,7 @@ HELP: ( ... layout -- tuple ) HELP: new { $values { "class" tuple-class } { "tuple" tuple } } -{ $description "Creates a new instance of " { $snippet "class" } " with all slots set to their initial values (see" { $link "tuple-declarations" } ")." } +{ $description "Creates a new instance of " { $snippet "class" } " with all slots set to their initial values (see " { $link "tuple-declarations" } ")." } { $examples { $example "USING: kernel prettyprint ;" diff --git a/core/combinators/combinators-docs.factor b/core/combinators/combinators-docs.factor index f8a23e179b..1e6c9295d3 100644 --- a/core/combinators/combinators-docs.factor +++ b/core/combinators/combinators-docs.factor @@ -60,10 +60,8 @@ $nl ARTICLE: "apply-combinators" "Apply combinators" "The apply combinators apply a single quotation to multiple values. The asterisk (" { $snippet "@" } ") suffixed to these words' names signifies that they are apply combinators." $nl -"Two quotations:" -{ $subsections bi@ 2bi@ } -"Three quotations:" -{ $subsections tri@ 2tri@ } +"One quotation:" +{ $subsections bi@ 2bi@ tri@ 2tri@ } "A pair of condition words built from " { $link bi@ } " to test two values:" { $subsections both? either? } "All of the apply combinators are equivalent to using the corresponding " { $link "spread-combinators" } " with the same quotation supplied for every value." ; diff --git a/core/definitions/definitions-docs.factor b/core/definitions/definitions-docs.factor index 0d207d9cc6..049104e61c 100644 --- a/core/definitions/definitions-docs.factor +++ b/core/definitions/definitions-docs.factor @@ -26,9 +26,9 @@ $nl { $code "USING: io sequences ;" "IN: a" - ": hello \"Hello\" ;" - ": world \"world\" ;" - ": hello-world hello " " world 3append print ;" + ": hello ( -- str ) \"Hello\" ;" + ": world ( -- str ) \"world\" ;" + ": hello-world ( -- ) hello \" \" world 3append print ;" } "The definitions for " { $snippet "hello" } ", " { $snippet "world" } ", and " { $snippet "hello-world" } " are in the dictionary." $nl @@ -36,9 +36,9 @@ $nl { $code "USING: namespaces ;" "IN: a" - ": hello \"Hello\" % ;" - ": hello-world [ hello " " % world ] \"\" make ;" - ": world \"world\" % ;" + ": hello ( -- ) \"Hello\" % ;" + ": hello-world ( -- str ) [ hello \" \" % world ] \"\" make ;" + ": world ( -- ) \"world\" % ;" } "Note that the developer has made a mistake, placing the definition of " { $snippet "world" } " " { $emphasis "after" } " its usage in " { $snippet "hello-world" } "." $nl diff --git a/core/generic/generic-docs.factor b/core/generic/generic-docs.factor index f4edb5e8ba..4b78f22f04 100644 --- a/core/generic/generic-docs.factor +++ b/core/generic/generic-docs.factor @@ -11,12 +11,12 @@ $nl { $code "GENERIC: explain ( object -- )" "M: object explain drop \"an object\" print ;" - "M: generic explain drop \"a class word\" print ;" - "M: class explain drop \"a generic word\" print ;" + "M: generic explain drop \"a generic word\" print ;" + "M: class explain drop \"a class word\" print ;" } "The linear order is the following, from least-specific to most-specific:" { $code "{ object generic class }" } -"Neither " { $link class } " nor " { $link generic } " are subclasses of each other, and their intersection is non-empty. Calling " { $snippet "explain" } " with a word on the stack that is both a class and a generic word will print " { $snippet "a generic word" } " because " { $link class } " precedes " { $link generic } " in the class linearization order. (One example of a word which is both a class and a generic word is the class of classes, " { $link class } ", which is also a word to get the class of an object.)" +"Neither " { $link class } " nor " { $link generic } " are subclasses of each other, and their intersection is non-empty. Calling " { $snippet "explain" } " with a word on the stack that is both a class and a generic word will print " { $snippet "a class word" } " because " { $link class } " is more specific than " { $link generic } " in the class linearization order. (One example of a word which is both a class and a generic word is the class of classes, " { $link class } ", which is also a word to get the class of an object.)" $nl "The " { $link order } " word can be useful to clarify method dispatch order:" { $subsections order } ; @@ -24,7 +24,7 @@ $nl ARTICLE: "generic-introspection" "Generic word introspection" "In most cases, generic words and methods are defined at parse time with " { $link POSTPONE: GENERIC: } " (or some other parsing word) and " { $link POSTPONE: M: } "." $nl -"Sometimes, generic words need to be inspected defined at run time; words for performing these tasks are found in the " { $vocab-link "generic" } " vocabulary." +"Sometimes, generic words need to be inspected or defined at run time; words for performing these tasks are found in the " { $vocab-link "generic" } " vocabulary." $nl "The set of generic words is a class which implements the " { $link "definition-protocol" } ":" { $subsections @@ -86,7 +86,7 @@ $nl } ; ARTICLE: "generic" "Generic words and methods" -"A " { $emphasis "generic word" } " is composed of zero or more " { $emphasis "methods" } " together with a " { $emphasis "method combination" } ". A method " { $emphasis "specializes" } " on a class; when a generic word executed, the method combination chooses the most appropriate method and calls its definition." +"A " { $emphasis "generic word" } " is composed of zero or more " { $emphasis "methods" } " together with a " { $emphasis "method combination" } ". A method " { $emphasis "specializes" } " on a class; when a generic word is executed, the method combination chooses the most appropriate method and calls its definition." $nl "A generic word behaves roughly like a long series of class predicate conditionals in a " { $link cond } " form, however methods can be defined in independent source files, reducing coupling and increasing extensibility. The method combination determines which object the generic word will " { $emphasis "dispatch" } " on; this could be the top of the stack, or some other value." $nl diff --git a/core/growable/growable-docs.factor b/core/growable/growable-docs.factor index 9f3db2bd37..12a2da1525 100644 --- a/core/growable/growable-docs.factor +++ b/core/growable/growable-docs.factor @@ -3,7 +3,7 @@ sequences.private ; IN: growable ARTICLE: "growable" "Resizable sequence implementation" -"Resizable sequences are implementing by having a wrapper object hold a reference to an underlying sequence, together with a fill pointer indicating how many elements of the underlying sequence are occupied. When the fill pointer exceeds the underlying sequence capacity, the underlying sequence grows." +"Resizable sequences are implemented by having a wrapper object hold a reference to an underlying sequence, together with a fill pointer indicating how many elements of the underlying sequence are occupied. When the fill pointer exceeds the underlying sequence capacity, the underlying sequence grows." $nl "There is a resizable sequence mixin:" { $subsections growable } diff --git a/core/hashtables/hashtables-docs.factor b/core/hashtables/hashtables-docs.factor index f239458355..e0397e2042 100644 --- a/core/hashtables/hashtables-docs.factor +++ b/core/hashtables/hashtables-docs.factor @@ -42,7 +42,7 @@ $nl ARTICLE: "hashtables.keys" "Hashtable keys" "Hashtables rely on the " { $link hashcode } " word to rapidly locate values associated with keys. The objects used as keys in a hashtable must obey certain restrictions." $nl -"The " { $link hashcode } " of a key is a function of the its slot values, and if the hashcode changes then the hashtable will be left in an inconsistent state. The easiest way to avoid this problem is to never mutate objects used as hashtable keys." +"The " { $link hashcode } " of a key is a function of its slot values, and if the hashcode changes then the hashtable will be left in an inconsistent state. The easiest way to avoid this problem is to never mutate objects used as hashtable keys." $nl "In certain advanced applications, this cannot be avoided and the best design involves mutating hashtable keys. In this case, a custom " { $link hashcode* } " method must be defined which only depends on immutable slots." $nl diff --git a/core/parser/parser-docs.factor b/core/parser/parser-docs.factor index 42903a2cec..3062f55a42 100644 --- a/core/parser/parser-docs.factor +++ b/core/parser/parser-docs.factor @@ -87,7 +87,7 @@ $nl "Also, top-level forms run in a new dynamic scope, so using " { $link set } " to store values is almost always wrong, since the values will be lost after the top-level form completes. To save values computed by a top-level form, either use " { $link set-global } " or define a new word with the value." ; ARTICLE: "parser" "The parser" -"The Factor parser reading textual representations of objects and definitions, with all syntax determined by " { $link "parsing-words" } ". The parser is implemented in the " { $vocab-link "parser" } " vocabulary, with standard syntax in the " { $vocab-link "syntax" } " vocabulary. See " { $link "syntax" } " for a description of standard syntax." +"The Factor parser reads textual representations of objects and definitions, with all syntax determined by " { $link "parsing-words" } ". The parser is implemented in the " { $vocab-link "parser" } " vocabulary, with standard syntax in the " { $vocab-link "syntax" } " vocabulary. See " { $link "syntax" } " for a description of standard syntax." $nl "The parser cross-references " { $link "source-files" } " and " { $link "definitions" } ". This functionality is used for improved error checking, as well as tools such as " { $link "tools.crossref" } " and " { $link "editor" } "." $nl diff --git a/core/syntax/syntax-docs.factor b/core/syntax/syntax-docs.factor index e0b6c1acb9..f587bcaee0 100644 --- a/core/syntax/syntax-docs.factor +++ b/core/syntax/syntax-docs.factor @@ -185,7 +185,7 @@ ARTICLE: "syntax-literals" "Literals" $nl "If a quotation contains a literal object, the same literal object instance is used each time the quotation executes; that is, literals are “live”." $nl -"Using mutable object literals in word definitions requires care, since if those objects are mutated, the actual word definition will be changed, which is in most cases not what you would expect. Literals should be " { $link clone } "d before being passed to word which may potentially mutate them." +"Using mutable object literals in word definitions requires care, since if those objects are mutated, the actual word definition will be changed, which is in most cases not what you would expect. Literals should be " { $link clone } "d before being passed to a word which may potentially mutate them." { $subsections "syntax-numbers" "syntax-words" diff --git a/core/vocabs/loader/loader-docs.factor b/core/vocabs/loader/loader-docs.factor index f2da4a1383..7d00cbe2ad 100644 --- a/core/vocabs/loader/loader-docs.factor +++ b/core/vocabs/loader/loader-docs.factor @@ -15,7 +15,7 @@ $nl { $subsections add-vocab-root } ; ARTICLE: "vocabs.roots" "Vocabulary roots" -"The vocabulary loader searches for it in one of the root directories:" +"The vocabulary loader searches for vocabularies in one of the root directories:" { $subsections vocab-roots } "The default set of roots includes the following directories in the Factor source directory:" { $list