diff --git a/core/alien/c-types/c-types-docs.factor b/core/alien/c-types/c-types-docs.factor index 1fd8cafdcf..fe6873ac3a 100755 --- a/core/alien/c-types/c-types-docs.factor +++ b/core/alien/c-types/c-types-docs.factor @@ -84,11 +84,11 @@ HELP: alien>u16-string ( c-ptr -- string ) { $values { "c-ptr" c-ptr } { "string" string } } { $description "Reads a null-terminated UCS-2 string from the specified address." } ; -HELP: memory>byte-array ( base len -- string ) -{ $values { "base" c-ptr } { "len" "a non-negative integer" } { "byte-array" byte-array } } +HELP: memory>byte-array +{ $values { "alien" c-ptr } { "len" "a non-negative integer" } { "byte-array" byte-array } } { $description "Reads " { $snippet "len" } " bytes starting from " { $snippet "base" } " and stores them in a new byte array." } ; -HELP: byte-array>memory ( string base -- ) +HELP: byte-array>memory { $values { "byte-array" byte-array } { "base" c-ptr } } { $description "Writes a byte array to memory starting from the " { $snippet "base" } " address." } { $warning "This word is unsafe. Improper use can corrupt memory." } ; diff --git a/core/assocs/assocs-docs.factor b/core/assocs/assocs-docs.factor index 716ac64c9b..b6326e1c10 100755 --- a/core/assocs/assocs-docs.factor +++ b/core/assocs/assocs-docs.factor @@ -162,6 +162,7 @@ HELP: assoc-each { $description "Applies a quotation to each entry in the assoc." } { $examples { $example + "USING: assocs kernel math prettyprint ;" "H{ { \"bananas\" 5 } { \"apples\" 42 } { \"pears\" 17 } }" "0 swap [ nip + ] assoc-each ." "64" diff --git a/core/boxes/boxes-docs.factor b/core/boxes/boxes-docs.factor index b3b91d06d9..3b8caaca1b 100755 --- a/core/boxes/boxes-docs.factor +++ b/core/boxes/boxes-docs.factor @@ -19,7 +19,7 @@ HELP: box> { $errors "Throws an error if the box is empty." } ; HELP: ?box -{ $values { "box" box } { "value" "the value of the box or " { $link f } } { "?" "a boolean" } } +{ $values { "box" box } { "value/f" "the value of the box or " { $link f } } { "?" "a boolean" } } { $description "If the box is full, removes the value from the box and pushes " { $link t } ". If the box is empty pushes " { $snippet "f f" } "." } ; ARTICLE: "boxes" "Boxes" diff --git a/core/byte-vectors/byte-vectors.factor b/core/byte-vectors/byte-vectors.factor index 0acf06c0c1..6a08f657a2 100755 --- a/core/byte-vectors/byte-vectors.factor +++ b/core/byte-vectors/byte-vectors.factor @@ -6,7 +6,7 @@ IN: byte-vectors vector ( byte-array capacity -- byte-vector ) +: byte-array>vector ( byte-array length -- byte-vector ) byte-vector construct-boa ; inline PRIVATE> diff --git a/core/classes/classes-docs.factor b/core/classes/classes-docs.factor index 56dda6f904..766d9e5555 100755 --- a/core/classes/classes-docs.factor +++ b/core/classes/classes-docs.factor @@ -1,4 +1,4 @@ -USING: generic help.markup help.syntax kernel kernel.private +USING: help.markup help.syntax kernel kernel.private namespaces sequences words arrays layouts help effects math layouts classes.private classes.union classes.mixin classes.predicate ; @@ -79,7 +79,7 @@ HELP: class { $values { "object" object } { "class" class } } { $description "Outputs an object's canonical class. While an object may be an instance of more than one class, the canonical class is either its built-in class, or if the object is a tuple, its tuple class." } { $class-description "The class of all class words. Subclasses include " { $link builtin-class } ", " { $link union-class } ", " { $link mixin-class } ", " { $link predicate-class } " and " { $link tuple-class } "." } -{ $examples { $example "USE: classes" "1.0 class ." "float" } { $example "USE: classes" "TUPLE: point x y z ;\nT{ point f 1 2 3 } class ." "point" } } ; +{ $examples { $example "USING: classes prettyprint ;" "1.0 class ." "float" } { $example "USING: classes prettyprint ;" "TUPLE: point x y z ;\nT{ point f 1 2 3 } class ." "point" } } ; HELP: classes { $values { "seq" "a sequence of class words" } } @@ -89,14 +89,14 @@ HELP: builtin-class { $class-description "The class of built-in classes." } { $examples "The class of arrays is a built-in class:" - { $example "USE: classes" "array builtin-class? ." "t" } - "However, a literal array is not a built-in class; it is not even a class:" - { $example "USE: classes" "{ 1 2 3 } builtin-class? ." "f" } + { $example "USING: arrays classes prettyprint ;" "array builtin-class? ." "t" } + "However, an instance of the array class is not a built-in class; it is not even a class:" + { $example "USING: classes prettyprint ;" "{ 1 2 3 } builtin-class? ." "f" } } ; HELP: tuple-class { $class-description "The class of tuple class words." } -{ $examples { $example "USE: classes\nTUPLE: name title first last ;\nname tuple-class? ." "t" } } ; +{ $examples { $example "USING: classes prettyprint ;" "TUPLE: name title first last ;" "name tuple-class? ." "t" } } ; HELP: typemap { $var-description "Hashtable mapping unions to class words, used to implement " { $link class-and } " and " { $link class-or } "." } ; @@ -167,7 +167,7 @@ HELP: types HELP: class-empty? { $values { "class" "a class" } { "?" "a boolean" } } { $description "Tests if a class is a union class with no members." } -{ $examples { $example "USE: classes" "null class-empty? ." "t" } } ; +{ $examples { $example "USING: classes kernel prettyprint ;" "null class-empty? ." "t" } } ; HELP: (class<) { $values { "class1" "a class" } { "class2" "a class" } { "?" "a boolean" } } @@ -182,8 +182,6 @@ HELP: sort-classes { $values { "seq" "a sequence of class" } { "newseq" "a new seqence of classes" } } { $description "Outputs a topological sort of a sequence of classes. Larger classes come before their subclasses." } ; -{ sort-classes methods order } related-words - HELP: lookup-union { $values { "classes" "a hashtable mapping class words to themselves" } { "class" class } } { $description "Given a set of classes represented as a hashtable with equal keys and values, looks up a previously-defined union class having those members. If no union is defined, outputs " { $link object } "." } ; diff --git a/core/combinators/combinators-docs.factor b/core/combinators/combinators-docs.factor index 5b87297b0c..f5d4470bde 100755 --- a/core/combinators/combinators-docs.factor +++ b/core/combinators/combinators-docs.factor @@ -82,7 +82,7 @@ HELP: with-datastack { $values { "stack" sequence } { "quot" quotation } { "newstack" sequence } } { $description "Executes the quotation with the given data stack contents, and outputs the new data stack after the word returns. The input sequence is not modified. Does not affect the data stack in surrounding code, other than consuming the two inputs and pushing the output." } { $examples - { $example "{ 3 7 } [ + ] with-datastack ." "{ 10 }" } + { $example "USING: combinators math prettyprint ;" "{ 3 7 } [ + ] with-datastack ." "{ 10 }" } } ; HELP: recursive-hashcode diff --git a/core/compiler/errors/errors-docs.factor b/core/compiler/errors/errors-docs.factor index 678face309..6cce72eed0 100755 --- a/core/compiler/errors/errors-docs.factor +++ b/core/compiler/errors/errors-docs.factor @@ -24,8 +24,8 @@ HELP: compiler-error. { $description "Prints a compiler error to the " { $link stdio } " stream." } ; HELP: compiler-errors. -{ $values { "errors" "an assoc mapping words to errors" } } -{ $description "Prints a set of compiler errors to the " { $link stdio } " stream." } ; +{ $values { "type" symbol } } +{ $description "Prints compiler errors to the " { $link stdio } " stream. The type parameter is one of " { $link +error+ } ", " { $link +warning+ } ", or " { $link +linkage+ } "." } ; HELP: :errors { $description "Prints all serious compiler errors from the most recent compile to the " { $link stdio } " stream." } ; diff --git a/core/compiler/units/units-docs.factor b/core/compiler/units/units-docs.factor index d30c5457d5..74dac17be8 100755 --- a/core/compiler/units/units-docs.factor +++ b/core/compiler/units/units-docs.factor @@ -63,7 +63,7 @@ HELP: modify-code-heap ( alist -- ) { $notes "This word is called at the end of " { $link with-compilation-unit } "." } ; HELP: compile -{ $values { "seq" "a sequence of words" } } +{ $values { "words" "a sequence of words" } } { $description "Compiles a set of words." } ; HELP: compile-call diff --git a/core/continuations/continuations-docs.factor b/core/continuations/continuations-docs.factor index 9a26dbc67e..81063031f9 100755 --- a/core/continuations/continuations-docs.factor +++ b/core/continuations/continuations-docs.factor @@ -150,7 +150,7 @@ HELP: recover { $description "Calls the " { $snippet "try" } " quotation. If an exception is thrown in the dynamic extent of the " { $snippet "try" } " quotation, restores the data stack and calls the " { $snippet "recovery" } " quotation to handle the error." } ; HELP: ignore-errors -{ $values { "try" quotation } } +{ $values { "quot" quotation } } { $description "Calls the quotation. If an exception is thrown in the dynamic extent of the quotation, restores the data stack and returns." } ; HELP: rethrow diff --git a/core/effects/effects-docs.factor b/core/effects/effects-docs.factor index f473eb58c8..9e37ba4c85 100644 --- a/core/effects/effects-docs.factor +++ b/core/effects/effects-docs.factor @@ -58,7 +58,7 @@ HELP: effect>string { $values { "effect" effect } { "string" string } } { $description "Turns a stack effect object into a string mnemonic." } { $examples - { $example "USE: effects" "1 2 effect>string print" "( object -- object object )" } + { $example "USING: effects io ;" "1 2 effect>string print" "( object -- object object )" } } ; HELP: stack-effect diff --git a/core/generator/generator-docs.factor b/core/generator/generator-docs.factor index 4473df7277..432a2a0008 100755 --- a/core/generator/generator-docs.factor +++ b/core/generator/generator-docs.factor @@ -57,7 +57,7 @@ HELP: generate { $description "Generates machine code for " { $snippet "label" } " from " { $snippet "node" } ". The value of " { $snippet "word" } " is retained for debugging purposes; it is the word which will appear in a call stack trace if this compiled code block throws an error when run." } ; HELP: word-dataflow -{ $values { "word" word } { "effect" effect } { "dependencies" sequence } { "dataflow" "a dataflow graph" } } +{ $values { "word" word } { "effect" effect } { "dataflow" "a dataflow graph" } } { $description "Outputs the dataflow graph of a word, taking specializers into account (see " { $link "specializers" } ")." } ; HELP: define-intrinsics diff --git a/core/generic/generic-docs.factor b/core/generic/generic-docs.factor index b2fba47d3a..9b799d9143 100755 --- a/core/generic/generic-docs.factor +++ b/core/generic/generic-docs.factor @@ -1,6 +1,6 @@ -USING: help.markup help.syntax generic.math generic.standard -words classes definitions kernel alien combinators sequences -math quotations ; +USING: help.markup help.syntax words classes definitions kernel +alien sequences math quotations generic.standard generic.math +combinators ; IN: generic ARTICLE: "method-order" "Method precedence" @@ -33,8 +33,6 @@ $nl "New generic words can be defined:" { $subsection define-generic } { $subsection define-simple-generic } -"Methods are tuples:" -{ $subsection } "Methods can be added to existing generic words:" { $subsection define-method } "Method definitions can be looked up:" @@ -42,8 +40,10 @@ $nl { $subsection methods } "A generic word contains methods; the list of methods specializing on a class can also be obtained:" { $subsection implementors } -"Low-level words which rebuilds the generic word after methods are added or removed, or the method combination is changed:" +"Low-level word which rebuilds the generic word after methods are added or removed, or the method combination is changed:" { $subsection make-generic } +"Low-level method constructor:" +{ $subsection } "A " { $emphasis "method specifier" } " refers to a method and implements the " { $link "definition-protocol" } ":" { $subsection method-spec } ; @@ -126,7 +126,7 @@ HELP: method { method define-method POSTPONE: M: } related-words HELP: -{ $values { "def" "a quotation" } { "method" "a new method definition" } } +{ $values { "quot" quotation } { "class" class } { "generic" generic } { "method" "a new method definition" } } { $description "Creates a new method." } ; HELP: methods @@ -148,7 +148,7 @@ HELP: with-methods $low-level-note ; HELP: define-method -{ $values { "method" quotation } { "class" class } { "generic" generic } } +{ $values { "quot" quotation } { "class" class } { "generic" generic } } { $description "Defines a method. This is the runtime equivalent of " { $link POSTPONE: M: } "." } ; HELP: implementors @@ -158,3 +158,5 @@ HELP: implementors HELP: forget-methods { $values { "class" class } } { $description "Remove all method definitions which specialize on the class." } ; + +{ sort-classes methods order } related-words diff --git a/core/generic/generic.factor b/core/generic/generic.factor index f73579661d..3c83b87d49 100755 --- a/core/generic/generic.factor +++ b/core/generic/generic.factor @@ -74,7 +74,7 @@ M: method-body stack-effect "method-def" set ] H{ } make-assoc ; -: ( quot class generic -- word ) +: ( quot class generic -- method ) check-method [ make-method-def ] 3keep [ method-word-props ] 2keep diff --git a/core/generic/math/math-docs.factor b/core/generic/math/math-docs.factor index b1148bb34e..cbbf070398 100644 --- a/core/generic/math/math-docs.factor +++ b/core/generic/math/math-docs.factor @@ -1,26 +1,27 @@ USING: kernel generic help.markup help.syntax math classes -generic.math ; +sequences quotations ; +IN: generic.math HELP: math-upgrade -{ $values { "class1" "a class word" } { "class2" "a class word" } { "quot" "a quotation with stack effect " { $snippet "( n n -- n n )" } } } +{ $values { "class1" class } { "class2" class } { "quot" "a quotation with stack effect " { $snippet "( n n -- n n )" } } } { $description "Outputs a quotation for upgrading numberical types. It takes two numbers on the stack, an instance of " { $snippet "class1" } ", and an instance of " { $snippet "class2" } ", and converts the one with the lower priority to the higher priority type." } -{ $examples { $example "USE: generic.math" "fixnum bignum math-upgrade ." "[ [ >bignum ] dip ]" } } ; +{ $examples { $example "USING: generic.math math kernel prettyprint ;" "fixnum bignum math-upgrade ." "[ [ >bignum ] dip ]" } } ; HELP: no-math-method -{ $values { "left" "an object" } { "right" "an object" } { "generic" "a generic word" } } +{ $values { "left" "an object" } { "right" "an object" } { "generic" generic } } { $description "Throws a " { $link no-math-method } " error." } { $error-description "Thrown by generic words using the " { $link math-combination } " method combination if there is no suitable method defined for the two inputs." } ; HELP: math-method -{ $values { "word" "a generic word" } { "class1" "a class word" } { "class2" "a class word" } { "quot" "a quotation" } } +{ $values { "word" generic } { "class1" class } { "class2" class } { "quot" quotation } } { $description "Generates a definition for " { $snippet "word" } " when the two inputs are instances of " { $snippet "class1" } " and " { $snippet "class2" } ", respectively." } -{ $examples { $example "USE: generic.math" "\\ + fixnum float math-method ." "[ [ >float ] dip float+ ]" } } ; +{ $examples { $example "USING: generic.math math prettyprint ;" "\\ + fixnum float math-method ." "[ [ >float ] dip float+ ]" } } ; HELP: math-class { $class-description "The class of subtypes of " { $link number } " which are not " { $link null } "." } ; HELP: math-combination -{ $values { "word" "a generic word" } { "quot" "a quotation" } } +{ $values { "word" generic } { "quot" quotation } } { $description "Generates a double-dispatching word definition. Only methods defined on numerical classes and " { $link object } " take effect in the math combination. Methods defined on numerical classes are guaranteed to have their two inputs upgraded to the highest priority type of the two." $nl "The math method combination is used for binary operators such as " { $link + } " and " { $link * } "." @@ -40,5 +41,5 @@ HELP: math-generic { $class-description "The class of generic words using " { $link math-combination } "." } ; HELP: last/first -{ $values { "seq" "a sequence" } { "pair" "a two-element array" } } +{ $values { "seq" sequence } { "pair" "a two-element array" } } { $description "Creates an array holding the first and last element of the sequence." } ; diff --git a/core/generic/standard/standard-docs.factor b/core/generic/standard/standard-docs.factor index 820a027d10..a6a65bb62f 100644 --- a/core/generic/standard/standard-docs.factor +++ b/core/generic/standard/standard-docs.factor @@ -1,5 +1,5 @@ -USING: generic help.markup help.syntax sequences -generic.standard ; +USING: generic help.markup help.syntax sequences ; +IN: generic.standard HELP: no-method { $values { "object" "an object" } { "generic" "a generic word" } } diff --git a/core/growable/growable-docs.factor b/core/growable/growable-docs.factor index 02f6292001..9de3c8ab24 100755 --- a/core/growable/growable-docs.factor +++ b/core/growable/growable-docs.factor @@ -18,19 +18,19 @@ $nl ABOUT: "growable" HELP: set-fill -{ $values { "n" "a new fill pointer" } { "seq" "a resizable sequence" } } +{ $values { "n" "a new fill pointer" } { "seq" growable } } { $contract "Sets the fill pointer (number of occupied elements in the underlying storage) of a resizable sequence." } { $side-effects "seq" } -{ $warning "This word is in the " { $vocab-link "growable.private" } " vocabulary because it is not safe. Changing the fill pointer to a negative value, or a value higher than the underlying sequence length can lead to memory corruption. User code should use " { $link set-length } " instead." } ; +{ $warning "This word is not safe. Changing the fill pointer to a negative value, or a value higher than the underlying sequence length can lead to memory corruption. User code should use " { $link set-length } " instead." } ; HELP: underlying -{ $values { "seq" "a resizable sequence" } { "underlying" "the underlying sequence" } } +{ $values { "seq" growable } { "underlying" "the underlying sequence" } } { $contract "Outputs the underlying storage of a resizable sequence." } ; HELP: set-underlying -{ $values { "underlying" "a sequence" } { "seq" "a resizable sequence" } } +{ $values { "underlying" sequence } { "seq" growable } } { $contract "Modifies the underlying storage of a resizable sequence." } -{ $warning "This word is in the " { $vocab-link "growable.private" } " vocabulary because it is not safe. Setting an underlying sequence shorter than the fill pointer can lead to memory corruption." } ; +{ $warning "This word is not safe. Setting an underlying sequence shorter than the fill pointer can lead to memory corruption." } ; HELP: capacity { $values { "seq" "a vector or string buffer" } { "n" "the capacity of the sequence" } } @@ -41,7 +41,7 @@ HELP: new-size { $description "Computes the new size of a resizable sequence." } ; HELP: ensure -{ $values { "n" "a positive integer" } { "seq" "a resizable sequence" } } +{ $values { "n" "a positive integer" } { "seq" growable } } { $description "If " { $snippet "n" } " is less than the length of the sequence, does nothing. Otherwise, if " { $snippet "n" } " also exceeds the capacity of the underlying storage, the underlying storage is grown, and the fill pointer is reset. Finally, if " { $snippet "n" } " is greater than or equal to the length but less than the capacity of the underlying storage, the fill pointer is moved and nothing else is done." $nl "This word is used in the implementation of the " { $link set-nth } " generic for sequences supporting the resizable sequence protocol (see " { $link "growable" } ")." diff --git a/core/hashtables/hashtables-docs.factor b/core/hashtables/hashtables-docs.factor index 563a59d20f..d62afdffb5 100755 --- a/core/hashtables/hashtables-docs.factor +++ b/core/hashtables/hashtables-docs.factor @@ -128,14 +128,14 @@ HELP: prune { $values { "seq" "a sequence" } { "newseq" "a sequence" } } { $description "Outputs a new sequence with each distinct element of " { $snippet "seq" } " appearing only once. Elements are compared for equality using " { $link = } " and elements are ordered according to their position in " { $snippet "seq" } "." } { $examples - { $example "USE: hashtables" "{ 1 1 t 3 t } prune ." "V{ 1 t 3 }" } + { $example "USING: hashtables prettyprint ;" "{ 1 1 t 3 t } prune ." "V{ 1 t 3 }" } } ; HELP: all-unique? { $values { "seq" sequence } { "?" "a boolean" } } { $description "Tests whether a sequence contains any repeated elements." } { $example - "USE: combinators.lib" + "USING: hashtables prettyprint ;" "{ 0 1 1 2 3 5 } all-unique? ." "f" } ; diff --git a/core/heaps/heaps-docs.factor b/core/heaps/heaps-docs.factor index 1c641662a9..f9224eafeb 100755 --- a/core/heaps/heaps-docs.factor +++ b/core/heaps/heaps-docs.factor @@ -77,6 +77,7 @@ HELP: heap-size { $description "Returns the number of key/value pairs in the heap." } ; HELP: heap-delete -{ $values { "heap" "a heap" } { "key" object } { "value" object } } -{ $description "Output and remove the first element in the heap." } +{ $values { "entry" entry } { "heap" "a heap" } } +{ $description "Remove the specified entry from the heap." } +{ $errors "Throws an error if the entry is from another heap or if it has already been deleted." } { $side-effects "heap" } ; diff --git a/core/io/crc32/crc32-docs.factor b/core/io/crc32/crc32-docs.factor index 3855c77cd8..7f85ee2b4e 100644 --- a/core/io/crc32/crc32-docs.factor +++ b/core/io/crc32/crc32-docs.factor @@ -6,7 +6,7 @@ HELP: crc32 { $description "Computes the CRC32 checksum of a sequence of bytes." } ; HELP: lines-crc32 -{ $values { "lines" "a sequence of strings" } { "n" integer } } +{ $values { "seq" "a sequence of strings" } { "n" integer } } { $description "Computes the CRC32 checksum of a sequence of lines of bytes." } ; ARTICLE: "io.crc32" "CRC32 checksum calculation" diff --git a/core/io/files/files-docs.factor b/core/io/files/files-docs.factor index 9609cd123b..625934e7af 100755 --- a/core/io/files/files-docs.factor +++ b/core/io/files/files-docs.factor @@ -104,18 +104,18 @@ HELP: path-separator? HELP: parent-directory { $values { "path" "a pathname string" } { "parent" "a pathname string" } } { $description "Strips the last component off a pathname." } -{ $examples { $example "USE: io.files" "\"/etc/passwd\" parent-directory print" "/etc/" } } ; +{ $examples { $example "USING: io io.files ;" "\"/etc/passwd\" parent-directory print" "/etc/" } } ; HELP: file-name { $values { "path" "a pathname string" } { "string" string } } { $description "Outputs the last component of a pathname string." } { $examples - { "\"/usr/bin/gcc\" file-name ." "\"gcc\"" } - { "\"/usr/libexec/awk/\" file-name ." "\"awk\"" } + { $example "USING: io.files prettyprint ;" "\"/usr/bin/gcc\" file-name ." "\"gcc\"" } + { $example "USING: io.files prettyprint ;" "\"/usr/libexec/awk/\" file-name ." "\"awk\"" } } ; HELP: -{ $values { "path" "a pathname string" } { "encoding" "an encoding descriptors" } +{ $values { "path" "a pathname string" } { "encoding" "an encoding descriptor" { "stream" "an input stream" } } { "stream" "an input stream" } } { $description "Outputs an input stream for reading from the specified pathname using the given encoding." } { $errors "Throws an error if the file is unreadable." } ; diff --git a/core/io/streams/byte-array/byte-array-docs.factor b/core/io/streams/byte-array/byte-array-docs.factor index 8e0b97e06b..741725af41 100644 --- a/core/io/streams/byte-array/byte-array-docs.factor +++ b/core/io/streams/byte-array/byte-array-docs.factor @@ -13,21 +13,22 @@ ARTICLE: "io.streams.byte-array" "Byte-array streams" HELP: { $values { "byte-array" byte-array } - { "encoding" "an encoding descriptor" } } -{ $description "Provides an input stream reading off the given byte array using the given encoding." } ; + { "encoding" "an encoding descriptor" } + { "stream" "a new byte reader" } } +{ $description "Creates an input stream reading from a byte array using an encoding." } ; HELP: { $values { "encoding" "an encoding descriptor" } - { "stream" "an output stream" } } -{ $description "Provides an output stream, putting things in the given encoding, storing everything written to it in a byte-array." } ; + { "stream" "a new byte writer" } } +{ $description "Creates an output stream writing data to a byte array using an encoding." } ; HELP: with-byte-reader { $values { "encoding" "an encoding descriptor" } { "quot" quotation } { "byte-array" byte-array } } -{ $description "Calls the quotation in a new dynamic scope with " { $link stdio } " rebound to an input stream reading the byte array in the given encoding from beginning to end." } ; +{ $description "Calls the quotation in a new dynamic scope with " { $link stdio } " rebound to an input stream for reading from a byte array using an encoding." } ; HELP: with-byte-writer { $values { "encoding" "an encoding descriptor" } { "quot" quotation } { "byte-array" byte-array } } -{ $description "Calls the quotation in a new dynamic scope with " { $link stdio } " rebound to a new byte array writer, putting things in the given encoding. The accumulated byte array is output when the quotation returns." } ; +{ $description "Calls the quotation in a new dynamic scope with " { $link stdio } " rebound to an output stream writing data to a byte array using an encoding." } ; diff --git a/core/kernel/kernel-docs.factor b/core/kernel/kernel-docs.factor index 2f80e3c368..963b646661 100755 --- a/core/kernel/kernel-docs.factor +++ b/core/kernel/kernel-docs.factor @@ -264,7 +264,7 @@ HELP: compare { $values { "obj1" object } { "obj2" object } { "quot" "a quotation with stack effect " { $snippet "( obj -- newobj )" } } { "n" integer } } { $description "Compares the results of applying the quotation to both objects via " { $link <=> } "." } { $examples - { $example "\"hello\" \"hi\" [ length ] compare ." "3" } + { $example "USING: kernel prettyprint sequences ;" "\"hello\" \"hi\" [ length ] compare ." "3" } } ; HELP: clone @@ -296,9 +296,9 @@ HELP: and { $notes "This word implements boolean and, so applying it to integers will not yield useful results (all integers have a true value). Bitwise and is the " { $link bitand } " word." } { $examples "Usually only the boolean value of the result is used, however you can also explicitly rely on the behavior that if both inputs are true, the second is output:" - { $example "t f and ." "f" } - { $example "t 7 and ." "7" } - { $example "\"hi\" 12.0 and ." "12.0" } + { $example "USING: kernel prettyprint ;" "t f and ." "f" } + { $example "USING: kernel prettyprint ;" "t 7 and ." "7" } + { $example "USING: kernel prettyprint ;" "\"hi\" 12.0 and ." "12.0" } } ; HELP: or @@ -307,8 +307,8 @@ HELP: or { $notes "This word implements boolean inclusive or, so applying it to integers will not yield useful results (all integers have a true value). Bitwise inclusive or is the " { $link bitor } " word." } { $examples "Usually only the boolean value of the result is used, however you can also explicitly rely on the behavior that the result will be the first true input:" - { $example "t f or ." "t" } - { $example "\"hi\" 12.0 or ." "\"hi\"" } + { $example "USING: kernel prettyprint ;" "t f or ." "t" } + { $example "USING: kernel prettyprint ;" "\"hi\" 12.0 or ." "\"hi\"" } } ; HELP: xor @@ -320,23 +320,21 @@ HELP: both? { $values { "quot" "a quotation with stack effect " { $snippet "( obj -- ? )" } } { "x" object } { "y" object } { "?" "a boolean" } } { $description "Tests if the quotation yields a true value when applied to both " { $snippet "x" } " and " { $snippet "y" } "." } { $examples - { $example "3 5 [ odd? ] both? ." "t" } - { $example "12 7 [ even? ] both? ." "f" } + { $example "USING: kernel math prettyprint ;" "3 5 [ odd? ] both? ." "t" } + { $example "USING: kernel math prettyprint ;" "12 7 [ even? ] both? ." "f" } } ; HELP: either? { $values { "quot" "a quotation with stack effect " { $snippet "( obj -- ? )" } } { "x" object } { "y" object } { "?" "a boolean" } } { $description "Tests if the quotation yields a true value when applied to either " { $snippet "x" } " or " { $snippet "y" } "." } { $examples - { $example "3 6 [ odd? ] either? ." "t" } - { $example "5 7 [ even? ] either? ." "f" } + { $example "USING: kernel math prettyprint ;" "3 6 [ odd? ] either? ." "t" } + { $example "USING: kernel math prettyprint ;" "5 7 [ even? ] either? ." "f" } } ; -HELP: call ( callable -- ) -{ $values { "quot" callable } } -{ $description "Calls a quotation." -$nl -"Under the covers, pushes the current call frame on the call stack, and set the call frame to the given quotation." } +HELP: call +{ $values { "callable" callable } } +{ $description "Calls a quotation." } { $examples "The following two lines are equivalent:" { $code "2 [ 2 + 3 * ] call" "2 2 + 3 *" } @@ -489,9 +487,9 @@ HELP: curry ( obj quot -- curry ) $nl "This operation is efficient and does not copy the quotation." } { $examples - { $example "5 [ . ] curry ." "[ 5 . ]" } - { $example "\\ = [ see ] curry ." "[ \\ = see ]" } - { $example "{ 1 2 3 } 2 [ - ] curry map ." "{ -1 0 1 }" } + { $example "USING: kernel prettyprint ;" "5 [ . ] curry ." "[ 5 . ]" } + { $example "USING: kernel prettyprint ;" "\\ = [ see ] curry ." "[ \\ = see ]" } + { $example "USING: kernel math prettyprint sequences ;" "{ 1 2 3 } 2 [ - ] curry map ." "{ -1 0 1 }" } } ; HELP: 2curry @@ -499,7 +497,7 @@ HELP: 2curry { $description "Outputs a " { $link callable } " which pushes " { $snippet "obj1" } " and " { $snippet "obj2" } " and then calls " { $snippet "quot" } "." } { $notes "This operation is efficient and does not copy the quotation." } { $examples - { $example "5 4 [ + ] 2curry ." "[ 5 4 + ]" } + { $example "USING: kernel math prettyprint ;" "5 4 [ + ] 2curry ." "[ 5 4 + ]" } } ; HELP: 3curry @@ -516,7 +514,7 @@ HELP: with } { $notes "This operation is efficient and does not copy the quotation." } { $examples - { $example "2 { 1 2 3 } [ - ] with map ." "{ 1 0 -1 }" } + { $example "USING: kernel math prettyprint sequences ;" "2 { 1 2 3 } [ - ] with map ." "{ 1 0 -1 }" } } ; HELP: compose diff --git a/core/listener/listener-docs.factor b/core/listener/listener-docs.factor index ca1027dbc5..755c79ac68 100755 --- a/core/listener/listener-docs.factor +++ b/core/listener/listener-docs.factor @@ -31,8 +31,8 @@ HELP: listener-hook { $var-description "Variable holding a quotation called by the listener before reading an input expression. The UI sets this variable to a quotation which updates the stack display in a listener gadget." } ; HELP: read-quot -{ $values { "stream" "an input stream" } { "quot/f" "a parsed quotation, or " { $link f } " indicating end of file" } } -{ $description "Reads a Factor expression from the stream, possibly spanning more than line. Additional lines of input are read while the parser stack height is greater than one. Since structural parsing words push partial quotations on the stack, this will keep on reading input until all delimited parsing words are terminated." } ; +{ $values { "quot/f" "a parsed quotation, or " { $link f } " indicating end of file" } } +{ $description "Reads a Factor expression which possibly spans more than one line from " { $link stdio } " stream. Additional lines of input are read while the parser stack height is greater than one. Since structural parsing words push partial quotations on the stack, this will keep on reading input until all delimited parsing words are terminated." } ; HELP: listen { $description "Prompts for an expression on the " { $link stdio } " stream and evaluates it. On end of file, " { $link quit-flag } " is set to terminate the listener loop." } diff --git a/core/listener/listener.factor b/core/listener/listener.factor index 61d3f9836d..16ee2705fe 100755 --- a/core/listener/listener.factor +++ b/core/listener/listener.factor @@ -38,7 +38,7 @@ M: object stream-read-quot M: duplex-stream stream-read-quot duplex-stream-in stream-read-quot ; -: read-quot ( -- quot ) stdio get stream-read-quot ; +: read-quot ( -- quot/f ) stdio get stream-read-quot ; : bye ( -- ) quit-flag on ; diff --git a/core/math/intervals/intervals-docs.factor b/core/math/intervals/intervals-docs.factor index 09afded43c..7eb20090ab 100644 --- a/core/math/intervals/intervals-docs.factor +++ b/core/math/intervals/intervals-docs.factor @@ -213,41 +213,41 @@ HELP: incomparable { $description "Output value from " { $link interval<= } ", " { $link interval< } ", " { $link interval>= } " and " { $link interval> } " in the case where the result of the comparison is ambiguous." } ; HELP: interval<= -{ $values { "int" interval } { "n" real } { "?" "a boolean or " { $link incomparable } } } -{ $description "Compares " { $snippet "int" } " with " { $snippet "n" } ", and outputs one of the following:" +{ $values { "i1" interval } { "i2" interval } { "?" "a boolean or " { $link incomparable } } } +{ $description "Compares " { $snippet "i1" } " with " { $snippet "i2" } ", and outputs one of the following:" { $list - { { $link t } " if every point in " { $snippet "int" } " is less than or equal to " { $snippet "n" } } - { { $link f } " if every point in " { $snippet "int" } " is greater than " { $snippet "n" } } + { { $link t } " if every point in " { $snippet "i1" } " is less than or equal to every point in " { $snippet "i2" } } + { { $link f } " if every point in " { $snippet "i1" } " is greater than every point in " { $snippet "i2" } } { { $link incomparable } " if neither of the above conditions hold" } } } ; HELP: interval< -{ $values { "int" interval } { "n" real } { "?" "a boolean or " { $link incomparable } } } -{ $description "Compares " { $snippet "int" } " with " { $snippet "n" } ", and outputs one of the following:" +{ $values { "i1" interval } { "i2" interval } { "?" "a boolean or " { $link incomparable } } } +{ $description "Compares " { $snippet "i1" } " with " { $snippet "i2" } ", and outputs one of the following:" { $list - { { $link t } " if every point in " { $snippet "int" } " is less than " { $snippet "n" } } - { { $link f } " if every point in " { $snippet "int" } " is greater than or equal to " { $snippet "n" } } + { { $link t } " if every point in " { $snippet "i1" } " is less than every point in " { $snippet "i2" } } + { { $link f } " if every point in " { $snippet "i1" } " is greater than or equal to every point in " { $snippet "i2" } } { { $link incomparable } " if neither of the above conditions hold" } } } ; HELP: interval>= -{ $values { "int" interval } { "n" real } { "?" "a boolean or " { $link incomparable } } } -{ $description "Compares " { $snippet "int" } " with " { $snippet "n" } ", and outputs one of the following:" +{ $values { "i1" interval } { "i2" interval } { "?" "a boolean or " { $link incomparable } } } +{ $description "Compares " { $snippet "i1" } " with " { $snippet "i2" } ", and outputs one of the following:" { $list - { { $link t } " if every point in " { $snippet "int" } " is greater than or equal to " { $snippet "n" } } - { { $link f } " if every point in " { $snippet "int" } " is less than " { $snippet "n" } } + { { $link t } " if every point in " { $snippet "i1" } " is greater than or equal to every point in " { $snippet "i2" } } + { { $link f } " if every point in " { $snippet "i1" } " is less than every point in " { $snippet "i2" } } { { $link incomparable } " if neither of the above conditions hold" } } } ; HELP: interval> -{ $values { "int" interval } { "n" real } { "?" "a boolean or " { $link incomparable } } } -{ $description "Compares " { $snippet "int" } " with " { $snippet "n" } ", and outputs one of the following:" +{ $values { "i1" interval } { "i2" interval } { "?" "a boolean or " { $link incomparable } } } +{ $description "Compares " { $snippet "i1" } " with " { $snippet "i2" } ", and outputs one of the following:" { $list - { { $link t } " if every point in " { $snippet "int" } " is greater than " { $snippet "n" } } - { { $link f } " if every point in " { $snippet "int" } " is less than or equal to " { $snippet "n" } } + { { $link t } " if every point in " { $snippet "i1" } " is greater than every point in " { $snippet "i2" } } + { { $link f } " if every point in " { $snippet "i1" } " is less than or equal to every point in " { $snippet "i2" } } { { $link incomparable } " if neither of the above conditions hold" } } } ; diff --git a/core/math/math-docs.factor b/core/math/math-docs.factor index 1ec3592c79..6ec1c5790f 100755 --- a/core/math/math-docs.factor +++ b/core/math/math-docs.factor @@ -184,8 +184,8 @@ HELP: bitand { $values { "x" integer } { "y" integer } { "z" integer } } { $description "Outputs a new integer where each bit is set if and only if the corresponding bit is set in both inputs." } { $examples - { $example "BIN: 101 BIN: 10 bitand .b" "0" } - { $example "BIN: 110 BIN: 10 bitand .b" "10" } + { $example "USING: math prettyprint ;" "BIN: 101 BIN: 10 bitand .b" "0" } + { $example "USING: math prettyprint ;" "BIN: 110 BIN: 10 bitand .b" "10" } } { $notes "This word implements bitwise and, so applying it to booleans will throw an error. Boolean and is the " { $link and } " word." } ; @@ -193,8 +193,8 @@ HELP: bitor { $values { "x" integer } { "y" integer } { "z" integer } } { $description "Outputs a new integer where each bit is set if and only if the corresponding bit is set in at least one of the inputs." } { $examples - { $example "BIN: 101 BIN: 10 bitor .b" "111" } - { $example "BIN: 110 BIN: 10 bitor .b" "110" } + { $example "USING: math prettyprint ;" "BIN: 101 BIN: 10 bitor .b" "111" } + { $example "USING: math prettyprint ;" "BIN: 110 BIN: 10 bitor .b" "110" } } { $notes "This word implements bitwise inclusive or, so applying it to booleans will throw an error. Boolean inclusive or is the " { $link and } " word." } ; @@ -202,15 +202,15 @@ HELP: bitxor { $values { "x" integer } { "y" integer } { "z" integer } } { $description "Outputs a new integer where each bit is set if and only if the corresponding bit is set in exactly one of the inputs." } { $examples - { $example "BIN: 101 BIN: 10 bitxor .b" "111" } - { $example "BIN: 110 BIN: 10 bitxor .b" "100" } + { $example "USING: math prettyprint ;" "BIN: 101 BIN: 10 bitxor .b" "111" } + { $example "USING: math prettyprint ;" "BIN: 110 BIN: 10 bitxor .b" "100" } } { $notes "This word implements bitwise exclusive or, so applying it to booleans will throw an error. Boolean exclusive or is the " { $link xor } " word." } ; HELP: shift { $values { "x" integer } { "n" integer } { "y" integer } } { $description "Shifts " { $snippet "x" } " to the left by " { $snippet "n" } " bits if " { $snippet "n" } " is positive, or " { $snippet "-n" } " bits to the right if " { $snippet "n" } " is negative. A left shift of a fixnum may overflow, yielding a bignum. A right shift may result in bits ``falling off'' the right hand side and being discarded." } -{ $examples { $example "BIN: 101 5 shift .b" "10100000" } { $example "BIN: 11111 -2 shift .b" "111" } } ; +{ $examples { $example "USING: math prettyprint ;" "BIN: 101 5 shift .b" "10100000" } { $example "USING: math prettyprint ;" "BIN: 11111 -2 shift .b" "111" } } ; HELP: bitnot { $values { "x" integer } { "y" integer } } @@ -222,7 +222,7 @@ $nl HELP: bit? { $values { "x" integer } { "n" integer } { "?" "a boolean" } } { $description "Tests if the " { $snippet "n" } "th bit of " { $snippet "x" } " is set." } -{ $examples { $example "BIN: 101 2 bit? ." "t" } } ; +{ $examples { $example "USING: math prettyprint ;" "BIN: 101 2 bit? ." "t" } } ; HELP: log2 { $values { "x" "a positive integer" } { "n" integer } } @@ -295,9 +295,9 @@ HELP: 2/ { $values { "x" integer } { "y" integer } } { $description "Shifts " { $snippet "x" } " to the right by one bit." } { $examples - { $example "14 2/ ." "7" } - { $example "17 2/ ." "8" } - { $example "-17 2/ ." "-9" } + { $example "USING: math prettyprint ;" "14 2/ ." "7" } + { $example "USING: math prettyprint ;" "17 2/ ." "8" } + { $example "USING: math prettyprint ;" "-17 2/ ." "-9" } } { $notes "This word is not equivalent to " { $snippet "2 /" } " or " { $snippet "2 /i" } "; the name is historic and originates from the Forth programming language." } ; diff --git a/core/mirrors/mirrors-docs.factor b/core/mirrors/mirrors-docs.factor index 8da9e9dd69..140f92567b 100755 --- a/core/mirrors/mirrors-docs.factor +++ b/core/mirrors/mirrors-docs.factor @@ -29,7 +29,7 @@ HELP: { $description "Creates a " { $link mirror } " reflecting an object." } { $examples { $example - "USING: assocs mirrors ;" + "USING: assocs mirrors prettyprint ;" "TUPLE: circle center radius ;" "C: circle" "{ 100 50 } 15 >alist ." diff --git a/core/namespaces/namespaces-docs.factor b/core/namespaces/namespaces-docs.factor index 2d4b9a03b2..971477cd4d 100755 --- a/core/namespaces/namespaces-docs.factor +++ b/core/namespaces/namespaces-docs.factor @@ -87,7 +87,7 @@ HELP: +@ { $description "Adds " { $snippet "n" } " to the value of the variable. A variable value of " { $link f } " is interpreted as being zero." } { $side-effects "variable" } { $examples - { $example "SYMBOL: foo\n1 foo +@\n10 foo +@\nfoo get ." "11" } + { $example "USING: namespaces prettyprint ;" "SYMBOL: foo\n1 foo +@\n10 foo +@\nfoo get ." "11" } } ; HELP: inc @@ -168,7 +168,7 @@ HELP: building HELP: make { $values { "quot" quotation } { "exemplar" "a sequence" } { "seq" "a new sequence" } } { $description "Calls the quotation in a new " { $emphasis "dynamic scope" } ". The quotation and any words it calls can execute the " { $link , } " and " { $link % } " words to accumulate elements. When the quotation returns, all accumulated elements are collected into a sequence with the same type as " { $snippet "exemplar" } "." } -{ $examples { $example "[ 1 , 2 , 3 , ] { } make ." "{ 1 2 3 }" } } ; +{ $examples { $example "USING: namespaces prettyprint ;" "[ 1 , 2 , 3 , ] { } make ." "{ 1 2 3 }" } } ; HELP: , { $values { "elt" object } } diff --git a/core/parser/parser-docs.factor b/core/parser/parser-docs.factor index ce6a119e32..48f929b836 100755 --- a/core/parser/parser-docs.factor +++ b/core/parser/parser-docs.factor @@ -221,8 +221,8 @@ HELP: { $description "Creates a new " { $link parse-error } ", filling in the location information from the current " { $link lexer } "." } ; HELP: skip -{ $values { "i" "a starting index" } { "seq" "a sequence" } { "quot" "a quotation with stack effect " { $snippet "( elt -- ? )" } } { "n" integer } } -{ $description "Variant of " { $link find* } " that outputs the length of the sequence instead of " { $link f } " if no elements satisfy the predicate." } ; +{ $values { "i" "a starting index" } { "seq" sequence } { "?" "a boolean" } { "n" integer } } +{ $description "Skips to the first space character (if " { $snippet "boolean" } " is " { $link f } ") or the first non-space character (otherwise)." } ; HELP: change-column { $values { "lexer" lexer } { "quot" "a quotation with stack effect " { $snippet "( col line -- newcol )" } } } @@ -264,7 +264,7 @@ HELP: bad-number HELP: escape { $values { "escape" "a single-character escape" } { "ch" "a character" } } { $description "Converts from a single-character escape code and the corresponding character." } -{ $examples { $example "CHAR: n escape CHAR: \\n = ." "t" } } ; +{ $examples { $example "USING: kernel parser prettyprint ;" "CHAR: n escape CHAR: \\n = ." "t" } } ; HELP: parse-string { $values { "str" "a new " { $link string } } } @@ -340,8 +340,8 @@ HELP: no-word { $notes "Apart from a missing " { $link POSTPONE: USE: } ", this error can also indicate an ordering issue. In Factor, words must be defined before they can be called. Mutual recursion can be implemented via " { $link POSTPONE: DEFER: } "." } ; HELP: search -{ $values { "str" string } { "word" word } } -{ $description "Searches for a word by name in the current vocabulary search path. If no such word could be found, throws a " { $link no-word } " error. If the search path does not contain a word with this name but other vocabularies do, the error will have restarts offering to add vocabularies to the search path." } +{ $values { "str" string } { "word/f" "a word or " { $link f } } } +{ $description "Searches for a word by name in the current vocabulary search path. If no such word could be found, outputs " { $link f } "." } $parsing-note ; HELP: scan-word @@ -459,7 +459,7 @@ HELP: forget-smudged { $description "Forgets removed definitions and prints a warning message if any of them are still referenced from other source files." } ; HELP: finish-parsing -{ $values { "quot" "the quotation just parsed" } } +{ $values { "lines" "the lines of text just parsed" } { "quot" "the quotation just parsed" } } { $description "Records information to the current " { $link file } " and prints warnings about any removed definitions which are still in use." } { $notes "This is one of the factors of " { $link parse-stream } "." } ; diff --git a/core/prettyprint/prettyprint-docs.factor b/core/prettyprint/prettyprint-docs.factor index 69400d2527..7ea0f5c412 100755 --- a/core/prettyprint/prettyprint-docs.factor +++ b/core/prettyprint/prettyprint-docs.factor @@ -242,8 +242,8 @@ HELP: definer { $values { "defspec" "a definition specifier" } { "start" word } { "end" "a word or " { $link f } } } { $contract "Outputs the parsing words which delimit the definition." } { $examples - { $example ": foo ; \\ foo definer . ." ";\nPOSTPONE: :" } - { $example "SYMBOL: foo \\ foo definer . ." "f\nPOSTPONE: SYMBOL:" } + { $example "USING: definitions prettyprint ;" ": foo ; \\ foo definer . ." ";\nPOSTPONE: :" } + { $example "USING: definitions prettyprint ;" "SYMBOL: foo \\ foo definer . ." "f\nPOSTPONE: SYMBOL:" } } { $notes "This word is used in the implementation of " { $link see } "." } ; @@ -251,6 +251,6 @@ HELP: definition { $values { "defspec" "a definition specifier" } { "seq" "a sequence" } } { $contract "Outputs the body of a definition." } { $examples - { $example "USE: math" "\\ sq definition ." "[ dup * ]" } + { $example "USING: definitions math prettyprint ;" "\\ sq definition ." "[ dup * ]" } } { $notes "This word is used in the implementation of " { $link see } "." } ; diff --git a/core/quotations/quotations-docs.factor b/core/quotations/quotations-docs.factor index c30db0a4b8..74c296d94c 100755 --- a/core/quotations/quotations-docs.factor +++ b/core/quotations/quotations-docs.factor @@ -51,8 +51,8 @@ HELP: literalize { $values { "obj" object } { "wrapped" object } } { $description "Outputs an object which evaluates to " { $snippet "obj" } " when placed in a quotation. If " { $snippet "obj" } " is not self-evaluating (for example, it is a word), then it will be wrapped." } { $examples - { $example "USE: quotations" "5 literalize ." "5" } - { $example "USE: quotations" "[ + ] [ literalize ] map ." "[ \\ + ]" } + { $example "USING: prettyprint quotations ;" "5 literalize ." "5" } + { $example "USING: math prettyprint quotations sequences ;" "[ + ] [ literalize ] map ." "[ \\ + ]" } } ; { literalize curry POSTPONE: \ POSTPONE: W{ } related-words diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index 6e39bced07..9e8dcd6559 100755 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -288,8 +288,8 @@ HELP: new-resizable { $values { "len" "a non-negative integer" } { "seq" sequence } { "newseq" "a resizable mutable sequence" } } { $contract "Outputs a resizable mutable sequence with an initial capacity of " { $snippet "n" } " elements and zero length, which can hold the elements of " { $snippet "seq" } "." } { $examples - { $example "300 V{ } new-resizable ." "V{ }" } - { $example "300 SBUF\" \" new-resizable ." "SBUF\" \"" } + { $example "USING: prettyprint sequences ;" "300 V{ } new-resizable ." "V{ }" } + { $example "USING: prettyprint sequences ;" "300 SBUF\" \" new-resizable ." "SBUF\" \"" } } ; HELP: like @@ -435,14 +435,16 @@ HELP: reduce { $values { "seq" sequence } { "identity" object } { "quot" "a quotation with stack effect " { $snippet "( prev elt -- next )" } } { "result" "the final result" } } { $description "Combines successive elements of the sequence using a binary operation, and outputs the final result. On the first iteration, the two inputs to the quotation are " { $snippet "identity" } ", and the first element of the sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the corresponding element of the sequence." } { $examples - { $example "{ 1 5 3 } 0 [ + ] reduce ." "9" } + { $example "USING: math prettyprint sequences ;" "{ 1 5 3 } 0 [ + ] reduce ." "9" } } ; HELP: accumulate { $values { "identity" object } { "seq" sequence } { "quot" "a quotation with stack effect " { $snippet "( prev elt -- next )" } } { "final" "the final result" } { "newseq" "a new sequence" } } -{ $description "Combines successive elements of the sequence using a binary operation, and outputs a sequence of intermediate results together with the final result. On the first iteration, the two inputs to the quotation are " { $snippet "identity" } ", and the first element of the sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the corresponding element of the sequence. Given the empty sequence, outputs a one-element sequence consisting of " { $snippet "identity" } "." } +{ $description "Combines successive elements of the sequence using a binary operation, and outputs a sequence of intermediate results together with the final result. On the first iteration, the two inputs to the quotation are " { $snippet "identity" } ", and the first element of the sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the corresponding element of the sequence." +$nl +"When given the empty sequence, outputs an empty sequence together with the " { $snippet "identity" } "." } { $examples - { $example "{ 2 2 2 2 2 } 0 [ + ] accumulate . ." "{ 0 2 4 6 8 }\n10" } + { $example "USING: math prettyprint sequences ;" "{ 2 2 2 2 2 } 0 [ + ] accumulate . ." "{ 0 2 4 6 8 }\n10" } } ; HELP: map @@ -546,9 +548,9 @@ HELP: monotonic? { $description "Applies the relation to successive pairs of elements in the sequence, testing for a truth value. The relation should be a transitive relation, such as a total order or an equality relation." } { $examples "Testing if a sequence is non-decreasing:" - { $example "{ 1 1 2 } [ <= ] monotonic? ." "t" } + { $example "USING: math prettyprint sequences ;" "{ 1 1 2 } [ <= ] monotonic? ." "t" } "Testing if a sequence is decreasing:" - { $example "{ 9 8 6 7 } [ < ] monotonic? ." "f" } + { $example "USING: math prettyprint sequences ;" "{ 9 8 6 7 } [ < ] monotonic? ." "f" } } ; { monotonic? all-eq? all-equal? } related-words @@ -556,7 +558,7 @@ HELP: monotonic? HELP: interleave { $values { "seq" sequence } { "between" "a quotation" } { "quot" "a quotation with stack effect " { $snippet "( elt -- )" } } } { $description "Applies " { $snippet "quot" } " to each element in turn, also invoking " { $snippet "between" } " in-between each pair of elements." } -{ $example "{ \"a\" \"b\" \"c\" } [ \"X\" write ] [ write ] interleave" "aXbXc" } ; +{ $example "USING: io sequences ;" "{ \"a\" \"b\" \"c\" } [ \"X\" write ] [ write ] interleave" "aXbXc" } ; HELP: cache-nth { $values { "i" "a non-negative integer" } { "seq" "a mutable sequence" } { "quot" "a quotation with stack effect " { $snippet "( i -- elt )" } } { "elt" object } } @@ -590,7 +592,7 @@ HELP: memq? { $description "Tests if the sequence contains the object." } { $examples "This word uses identity comparison, so the following will most likely print " { $link f } ":" - { $example "\"hello\" { \"hello\" } memq? ." "f" } + { $example "USING: prettyprint sequences ;" "\"hello\" { \"hello\" } memq? ." "f" } } ; HELP: remove @@ -629,6 +631,7 @@ HELP: push-new { $description "Removes all elements equal to " { $snippet "elt" } ", and adds " { $snippet "elt" } " at the end of the sequence." } { $examples { $example + "USING: namespaces prettyprint sequences ;" "V{ \"beans\" \"salsa\" \"cheese\" } \"v\" set" "\"nachos\" \"v\" get push-new" "\"salsa\" \"v\" get push-new" @@ -645,7 +648,7 @@ HELP: add { $description "Outputs a new sequence obtained by adding " { $snippet "elt" } " at the end of " { $snippet "seq" } "." } { $errors "Throws an error if the type of " { $snippet "elt" } " is not permitted in sequences of the same class as " { $snippet "seq1" } "." } { $examples - { $example "{ 1 2 3 } 4 add ." "{ 1 2 3 4 }" } + { $example "USING: prettyprint sequences ;" "{ 1 2 3 } 4 add ." "{ 1 2 3 4 }" } } ; HELP: add* @@ -653,7 +656,7 @@ HELP: add* { $description "Outputs a new sequence obtained by adding " { $snippet "elt" } " at the beginning of " { $snippet "seq" } "." } { $errors "Throws an error if the type of " { $snippet "elt" } " is not permitted in sequences of the same class as " { $snippet "seq1" } "." } { $examples - { $example "{ 1 2 3 } 0 add* ." "{ 0 1 2 3 }" } +{ $example "USING: prettyprint sequences ;" "{ 1 2 3 } 0 add* ." "{ 0 1 2 3 }" } } ; HELP: seq-diff @@ -710,7 +713,7 @@ HELP: mismatch HELP: flip { $values { "matrix" "a sequence of equal-length sequences" } { "newmatrix" "a sequence of equal-length sequences" } } { $description "Transposes the matrix; that is, rows become columns and columns become rows." } -{ $examples { $example "{ { 1 2 3 } { 4 5 6 } } flip ." "{ { 1 4 } { 2 5 } { 3 6 } }" } } ; +{ $examples { $example "USING: prettyprint sequences ;" "{ { 1 2 3 } { 4 5 6 } } flip ." "{ { 1 4 } { 2 5 } { 3 6 } }" } } ; HELP: exchange { $values { "m" "a non-negative integer" } { "n" "a non-negative integer" } { "seq" "a mutable sequence" } } @@ -728,12 +731,12 @@ HELP: padding HELP: pad-left { $values { "seq" sequence } { "n" "a non-negative integer" } { "elt" object } { "padded" "a new sequence" } } { $description "Outputs a new sequence consisting of " { $snippet "seq" } " padded on the left with enough repetitions of " { $snippet "elt" } " to have the result be of length " { $snippet "n" } "." } -{ $examples { $example "{ \"ab\" \"quux\" } [ 5 CHAR: - pad-left print ] each" "---ab\n-quux" } } ; +{ $examples { $example "USING: io sequences ;" "{ \"ab\" \"quux\" } [ 5 CHAR: - pad-left print ] each" "---ab\n-quux" } } ; HELP: pad-right { $values { "seq" sequence } { "n" "a non-negative integer" } { "elt" object } { "padded" "a new sequence" } } { $description "Outputs a new sequence consisting of " { $snippet "seq" } " padded on the right with enough repetitions of " { $snippet "elt" } " to have the result be of length " { $snippet "n" } "." } -{ $examples { $example "{ \"ab\" \"quux\" } [ 5 CHAR: - pad-right print ] each" "ab---\nquux-" } } ; +{ $examples { $example "USING: io sequences ;" "{ \"ab\" \"quux\" } [ 5 CHAR: - pad-right print ] each" "ab---\nquux-" } } ; HELP: sequence= { $values { "seq1" sequence } { "seq2" sequence } { "?" "a boolean" } } @@ -798,6 +801,7 @@ HELP: ( seq n -- column ) { $description "Outputs a new virtual sequence which presents a fixed column of a matrix represented as a sequence of rows." "The " { $snippet "i" } "th element of a column is the " { $snippet "n" } "th element of the " { $snippet "i" } "th element of" { $snippet "seq" } ". Every element of " { $snippet "seq" } " must be a sequence, and all sequences must have equal length." } { $examples { $example + "USING: arrays prettyprint sequences ;" "{ { 1 2 3 } { 4 5 6 } { 7 8 9 } } 0 >array ." "{ 1 4 7 }" } @@ -813,8 +817,8 @@ HELP: ( len elt -- repetition ) { $values { "len" "a non-negative integer" } { "elt" object } { "repetition" repetition } } { $description "Creates a new " { $link repetition } "." } { $examples - { $example "10 \"X\" >array ." "{ \"X\" \"X\" \"X\" \"X\" \"X\" \"X\" \"X\" \"X\" \"X\" \"X\" }" } - { $example "10 \"X\" >array concat ." "\"XXXXXXXXXX\"" } + { $example "USING: arrays prettyprint sequences ;" "10 \"X\" >array ." "{ \"X\" \"X\" \"X\" \"X\" \"X\" \"X\" \"X\" \"X\" \"X\" \"X\" }" } + { $example "USING: prettyprint sequences ;" "10 \"X\" concat ." "\"XXXXXXXXXX\"" } } ; HELP: copy { $values { "src" sequence } { "i" "an index in " { $snippet "dest" } } { "dst" "a mutable sequence" } } @@ -936,7 +940,7 @@ HELP: unclip { $values { "seq" sequence } { "rest" sequence } { "first" object } } { $description "Outputs a tail sequence and the first element of " { $snippet "seq" } "; the tail sequence consists of all elements of " { $snippet "seq" } " but the first." } { $examples - { $example "{ 1 2 3 } unclip add ." "{ 2 3 1 }" } + { $example "USING: prettyprint sequences ;" "{ 1 2 3 } unclip add ." "{ 2 3 1 }" } } ; HELP: unclip-slice @@ -966,7 +970,7 @@ HELP: unfold { $description "Calls " { $snippet "pred" } " repeatedly. If the predicate yields " { $link f } ", stops, otherwise, calls " { $snippet "quot" } " to yield a value. Values are accumulated and returned in a sequence at the end." } { $examples "The following example divides a number by two until we reach zero, and accumulates intermediate results:" - { $example "1337 [ dup 0 > ] [ 2/ dup ] [ ] unfold nip ." "{ 668 334 167 83 41 20 10 5 2 1 0 }" } + { $example "USING: kernel math prettyprint sequences ;" "1337 [ dup 0 > ] [ 2/ dup ] [ ] unfold nip ." "{ 668 334 167 83 41 20 10 5 2 1 0 }" } "The " { $snippet "tail" } " quotation is used when the predicate produces more than one output value. In this case, we have to drop this value even if the predicate fails in order for stack inference to calculate a stack effect for the " { $link unfold } " call:" - { $unchecked-example "[ 10 random dup 1 > ] [ ] [ drop ] unfold ." "{ 8 2 2 9 }" } + { $unchecked-example "USING: kernel prettyprint random sequences ;" "[ 10 random dup 1 > ] [ ] [ drop ] unfold ." "{ 8 2 2 9 }" } } ; diff --git a/core/slots/slots-docs.factor b/core/slots/slots-docs.factor index d8c8f5fbba..d57c4053e6 100644 --- a/core/slots/slots-docs.factor +++ b/core/slots/slots-docs.factor @@ -68,7 +68,7 @@ HELP: reader-quot HELP: slot-reader { $class-description "The class of slot reader words." } { $examples - { $example "USING: classes slots ;" "TUPLE: circle center radius ;" "\\ circle-center slot-reader? ." "t" } + { $example "USING: classes prettyprint slots ;" "TUPLE: circle center radius ;" "\\ circle-center slot-reader? ." "t" } } ; HELP: define-reader @@ -83,7 +83,7 @@ HELP: writer-effect HELP: slot-writer { $class-description "The class of slot writer words." } { $examples - { $example "USING: classes slots ;" "TUPLE: circle center radius ;" "\\ set-circle-center slot-writer? ." "t" } + { $example "USING: classes prettyprint slots ;" "TUPLE: circle center radius ;" "\\ set-circle-center slot-writer? ." "t" } } ; HELP: define-writer diff --git a/core/source-files/source-files-docs.factor b/core/source-files/source-files-docs.factor index 36a7ae67bb..2371c27e52 100755 --- a/core/source-files/source-files-docs.factor +++ b/core/source-files/source-files-docs.factor @@ -51,7 +51,7 @@ HELP: record-modified $low-level-note ; HELP: record-checksum -{ $values { "source-file" source-file } { "contents" string } } +{ $values { "source-file" source-file } { "lines" "a sequence of strings" } } { $description "Records the CRC32 checksm of the source file's contents." } $low-level-note ; diff --git a/core/source-files/source-files.factor b/core/source-files/source-files.factor index 55300a3c29..98438b48d8 100755 --- a/core/source-files/source-files.factor +++ b/core/source-files/source-files.factor @@ -85,7 +85,7 @@ M: pathname where pathname-string 1 2array ; M: pathname forget* pathname-string forget-source ; -: rollback-source-file ( source-file -- ) +: rollback-source-file ( file -- ) dup source-file-definitions new-definitions get [ union ] 2map swap set-source-file-definitions ; diff --git a/core/splitting/splitting-docs.factor b/core/splitting/splitting-docs.factor index 2535f98524..5000dbf5fd 100644 --- a/core/splitting/splitting-docs.factor +++ b/core/splitting/splitting-docs.factor @@ -33,7 +33,7 @@ HELP: last-split1 HELP: split { $values { "seq" "a sequence" } { "separators" "a sequence" } { "pieces" "a new array" } } { $description "Splits " { $snippet "seq" } " at each occurrence of an element of " { $snippet "separators" } ", and outputs an array of pieces. The pieces do not include the elements along which the sequence was split." } -{ $examples { $example "USE: splitting" "\"hello world-how are you?\" \" -\" split ." "{ \"hello\" \"world\" \"how\" \"are\" \"you?\" }" } } ; +{ $examples { $example "USING: prettyprint splitting ;" "\"hello world-how are you?\" \" -\" split ." "{ \"hello\" \"world\" \"how\" \"are\" \"you?\" }" } } ; HELP: groups { $class-description "Instances are virtual sequences whose elements are fixed-length subsequences or slices of an underlying sequence. Groups are mutable and resizable if the underlying sequence is mutable and resizable, respectively." @@ -51,7 +51,7 @@ HELP: { $description "Outputs a virtual sequence whose elements are subsequences consisting of groups of " { $snippet "n" } " elements from the underlying sequence." } { $examples { $example - "USE: splitting" + "USING: arrays kernel prettyprint sequences splitting ;" "9 >array 3 dup reverse-here concat >array ." "{ 6 7 8 3 4 5 0 1 2 }" } } ; @@ -61,7 +61,7 @@ HELP: { $description "Outputs a virtual sequence whose elements are slices consisting of groups of " { $snippet "n" } " elements from the underlying sequence." } { $examples { $example - "USE: splitting" + "USING: arrays kernel prettyprint sequences splitting ;" "9 >array 3 " "dup [ reverse-here ] each concat >array ." "{ 2 1 0 5 4 3 8 7 6 }" @@ -90,5 +90,5 @@ HELP: string-lines { $values { "str" string } { "seq" "a sequence of strings" } } { $description "Splits a string along line breaks." } { $examples - { $example "USE: splitting" "\"Hello\\r\\nworld\\n\" string-lines ." "{ \"Hello\" \"world\" \"\" }" } + { $example "USING: prettyprint splitting ;" "\"Hello\\r\\nworld\\n\" string-lines ." "{ \"Hello\" \"world\" \"\" }" } } ; diff --git a/core/syntax/syntax-docs.factor b/core/syntax/syntax-docs.factor index eeb3f85962..dc06a239de 100755 --- a/core/syntax/syntax-docs.factor +++ b/core/syntax/syntax-docs.factor @@ -204,7 +204,7 @@ HELP: delimiter HELP: parsing { $syntax ": foo ... ; parsing" } { $description "Declares the most recently defined word as a parsing word." } -{ $examples "In the below example, the " { $snippet "world" } " word is never called, however its body references a parsing word which executes immediately:" { $example ": hello \"Hello parser!\" print ; parsing\n: world hello ;" "Hello parser!" } } ; +{ $examples "In the below example, the " { $snippet "world" } " word is never called, however its body references a parsing word which executes immediately:" { $example "USE: io" "<< : hello \"Hello parser!\" print ; parsing >>\n: world hello ;" "Hello parser!" } } ; HELP: inline { $syntax ": foo ... ; inline" } @@ -367,7 +367,7 @@ HELP: SYMBOL: { $syntax "SYMBOL: word" } { $values { "word" "a new word to define" } } { $description "Defines a new symbol word in the current vocabulary. Symbols push themselves on the stack when executed, and are used to identify variables (see " { $link "namespaces" } ") as well as for storing crufties in word properties (see " { $link "word-props" } ")." } -{ $examples { $example "SYMBOL: foo\nfoo ." "foo" } } ; +{ $examples { $example "USE: prettyprint" "SYMBOL: foo\nfoo ." "foo" } } ; { define-symbol POSTPONE: SYMBOL: } related-words @@ -424,19 +424,19 @@ HELP: " { $syntax "\"string...\"" } { $values { "string" "literal and escaped characters" } } { $description "Reads from the input string until the next occurrence of " { $link POSTPONE: " } ", and appends the resulting string to the parse tree. String literals cannot span multiple lines. Strings containing the " { $link POSTPONE: " } " character and various other special characters can be read by inserting escape sequences." } -{ $examples { $example "\"Hello\\nworld\" print" "Hello\nworld" } } ; +{ $examples { $example "USE: io" "\"Hello\\nworld\" print" "Hello\nworld" } } ; HELP: SBUF" { $syntax "SBUF\" string... \"" } { $values { "string" "literal and escaped characters" } } { $description "Reads from the input string until the next occurrence of " { $link POSTPONE: " } ", converts the string to a string buffer, and appends it to the parse tree." } -{ $examples { $example "SBUF\" Hello world\" >string print" "Hello world" } } ; +{ $examples { $example "USING: io strings ;" "SBUF\" Hello world\" >string print" "Hello world" } } ; HELP: P" { $syntax "P\" pathname\"" } { $values { "pathname" "a pathname string" } } { $description "Reads from the input string until the next occurrence of " { $link POSTPONE: " } ", creates a new " { $link pathname } ", and appends it to the parse tree." } -{ $examples { $example "USE: io.files" "P\" foo.txt\" pathname-string print" "foo.txt" } } ; +{ $examples { $example "USING: io io.files ;" "P\" foo.txt\" pathname-string print" "foo.txt" } } ; HELP: ( { $syntax "( inputs -- outputs )" } @@ -460,19 +460,19 @@ HELP: HEX: { $syntax "HEX: integer" } { $values { "integer" "hexadecimal digits (0-9, a-f, A-F)" } } { $description "Adds an integer read from a hexadecimal literal to the parse tree." } -{ $examples { $example "HEX: ff ." "255" } } ; +{ $examples { $example "USE: prettyprint" "HEX: ff ." "255" } } ; HELP: OCT: { $syntax "OCT: integer" } { $values { "integer" "octal digits (0-7)" } } { $description "Adds an integer read from an octal literal to the parse tree." } -{ $examples { $example "OCT: 31337 ." "13023" } } ; +{ $examples { $example "USE: prettyprint" "OCT: 31337 ." "13023" } } ; HELP: BIN: { $syntax "BIN: integer" } { $values { "integer" "binary digits (0 and 1)" } } { $description "Adds an integer read from an binary literal to the parse tree." } -{ $examples { $example "BIN: 100 ." "4" } } ; +{ $examples { $example "USE: prettyprint" "BIN: 100 ." "4" } } ; HELP: GENERIC: { $syntax "GENERIC: word" } @@ -500,6 +500,7 @@ HELP: HOOK: { $description "Defines a new hook word in the current vocabulary. Hook words are generic words which dispatch on the value of a variable, so methods are defined with " { $link POSTPONE: M: } ". Hook words differ from other generic words in that the dispatch value is removed from the stack before the chosen method is called." } { $examples { $example + "USING: io namespaces ;" "SYMBOL: transport" "TUPLE: land-transport ;" "TUPLE: air-transport ;" diff --git a/core/threads/threads-docs.factor b/core/threads/threads-docs.factor index d157907cc2..a2c50346df 100755 --- a/core/threads/threads-docs.factor +++ b/core/threads/threads-docs.factor @@ -73,8 +73,10 @@ HELP: self { $description "Pushes the currently-running thread." } ; HELP: -{ $values { "quot" quotation } { "name" string } { "error-handler" quotation } } -{ $description "Low-level thread constructor. The thread runs the quotation when spawned; the name is simply used to identify the thread for debugging purposes. The error handler is called if the thread's quotation throws an unhandled error; it should either print the error or notify another thread." } +{ $values { "quot" quotation } { "name" string } { "thread" thread } } +{ $description "Low-level thread constructor. The thread runs the quotation when spawned." +$nl +"The name is used to identify the thread for debugging purposes; see " { $link "tools.threads" } "." } { $notes "In most cases, user code should call " { $link spawn } " instead, however for control over the error handler quotation, threads can be created with " { $link } " then passed to " { $link (spawn) } "." } ; HELP: run-queue @@ -96,7 +98,7 @@ HELP: sleep-queue { $var-description "A " { $link min-heap } " storing the queue of sleeping threads." } ; HELP: sleep-time -{ $values { "ms" "a non-negative integer or " { $link f } } } +{ $values { "ms/f" "a non-negative integer or " { $link f } } } { $description "Outputs the time until the next sleeping thread is scheduled to wake up, which could be zero if there are threads in the run queue, or threads which need to wake up right now. If there are no runnable or sleeping threads, outputs " { $link f } "." } ; HELP: stop @@ -122,11 +124,15 @@ HELP: interrupt { $description "Interrupts a sleeping thread." } ; HELP: suspend -{ $values { "quot" "a quotation with stack effect " { $snippet "( thread -- )" } } { "obj" object } } -{ $description "Suspends the current thread and passes it to the quotation. After the quotation returns, control yields to the next runnable thread and the current thread does not execute again until it is resumed, and so the quotation must arrange for another thread to later resume the suspended thread with a call to " { $link resume } " or " { $link resume-with } "." } ; +{ $values { "quot" "a quotation with stack effect " { $snippet "( thread -- )" } } { "state" string } { "obj" object } } +{ $description "Suspends the current thread and passes it to the quotation." +$nl +"After the quotation returns, control yields to the next runnable thread and the current thread does not execute again until it is resumed, and so the quotation must arrange for another thread to later resume the suspended thread with a call to " { $link resume } " or " { $link resume-with } "." +$nl +"The status string is for debugging purposes; see " { $link "tools.threads" } "." } ; HELP: spawn -{ $values { "quot" quotation } { "name" string } } +{ $values { "quot" quotation } { "name" string } { "thread" thread } } { $description "Spawns a new thread. The thread begins executing the given quotation; the name is for debugging purposes. The new thread begins running immediately and the current thread is added to the end of the run queue." $nl "The new thread begins with an empty data stack, an empty retain stack, and an empty catch stack. The name stack is inherited from the parent thread but may be cleared with " { $link init-namespaces } "." } @@ -138,7 +144,7 @@ $nl } ; HELP: spawn-server -{ $values { "quot" "a quotation with stack effect " { $snippet "( -- ? )" } } { "name" string } } +{ $values { "quot" "a quotation with stack effect " { $snippet "( -- ? )" } } { "name" string } { "thread" thread } } { $description "Convenience wrapper around " { $link spawn } " which repeatedly calls the quotation in a new thread until it outputs " { $link f } "." } { $examples "A thread that runs forever:" diff --git a/core/tuples/tuples-docs.factor b/core/tuples/tuples-docs.factor index a4fe3265fc..c03b9784ee 100755 --- a/core/tuples/tuples-docs.factor +++ b/core/tuples/tuples-docs.factor @@ -180,6 +180,7 @@ HELP: construct-empty { $description "Creates a new instance of " { $snippet "class" } " with all slots initially set to " { $link f } "." } { $examples { $example + "USING: kernel prettyprint ;" "TUPLE: employee number name department ;" "employee construct-empty ." "T{ employee f f f f }" diff --git a/core/vectors/vectors.factor b/core/vectors/vectors.factor index ed97bcc0c4..1820c62ff4 100755 --- a/core/vectors/vectors.factor +++ b/core/vectors/vectors.factor @@ -5,7 +5,7 @@ IN: vectors vector ( byte-array capacity -- byte-vector ) +: array>vector ( array length -- vector ) vector construct-boa ; inline PRIVATE> diff --git a/core/vocabs/loader/loader-docs.factor b/core/vocabs/loader/loader-docs.factor index a306efbd68..9f7b2b5b9f 100755 --- a/core/vocabs/loader/loader-docs.factor +++ b/core/vocabs/loader/loader-docs.factor @@ -65,12 +65,12 @@ HELP: load-help? { $var-description "If set to a true value, documentation will be automatically loaded when vocabularies are loaded. This variable is usually on, except when Factor has been bootstrapped without the help system." } ; HELP: load-source -{ $values { "root" "a pathname string" } { "name" "a vocabulary name" } } -{ $description "Loads a vocabulary's source code from the specified vocabulary root." } ; +{ $values { "vocab" "a vocabulary specifier" } } +{ $description "Loads a vocabulary's source code." } ; HELP: load-docs -{ $values { "root" "a pathname string" } { "name" "a vocabulary name" } } -{ $description "If " { $link load-help? } " is on, loads a vocabulary's documentation from the specified vocabulary root." } ; +{ $values { "vocab" "a vocabulary specifier" } } +{ $description "If " { $link load-help? } " is on, loads a vocabulary's documentation." } ; HELP: reload { $values { "name" "a vocabulary name" } } diff --git a/core/vocabs/loader/loader.factor b/core/vocabs/loader/loader.factor index b21329de9c..885bccddd1 100755 --- a/core/vocabs/loader/loader.factor +++ b/core/vocabs/loader/loader.factor @@ -75,7 +75,7 @@ SYMBOL: load-help? : source-wasn't-loaded f swap set-vocab-source-loaded? ; -: load-source ( vocab-link -- ) +: load-source ( vocab -- ) [ source-wasn't-loaded ] keep [ vocab-source-path bootstrap-file ] keep source-was-loaded ; @@ -84,7 +84,7 @@ SYMBOL: load-help? : docs-weren't-loaded f swap set-vocab-docs-loaded? ; -: load-docs ( vocab-link -- ) +: load-docs ( vocab -- ) load-help? get [ [ docs-weren't-loaded ] keep [ vocab-docs-path ?run-file ] keep diff --git a/core/words/words-docs.factor b/core/words/words-docs.factor index 4903f8933b..eb1bd0908a 100755 --- a/core/words/words-docs.factor +++ b/core/words/words-docs.factor @@ -197,7 +197,7 @@ HELP: execute ( word -- ) { $values { "word" word } } { $description "Executes a word." } { $examples - { $example ": twice dup execute execute ;\n: hello \"Hello\" print ;\n\\ hello twice" "Hello\nHello" } + { $example "USING: kernel io words ;" ": twice dup execute execute ;\n: hello \"Hello\" print ;\n\\ hello twice" "Hello\nHello" } } ; HELP: word-props ( word -- props ) @@ -322,7 +322,7 @@ HELP: create HELP: constructor-word { $values { "name" string } { "vocab" string } { "word" word } } { $description "Creates a new word, surrounding " { $snippet "name" } " in angle brackets." } -{ $examples { $example "\"salmon\" \"scratchpad\" constructor-word ." "" } } ; +{ $examples { $example "USING: prettyprint words ;" "\"salmon\" \"scratchpad\" constructor-word ." "" } } ; HELP: forget-word { $values { "word" word } } diff --git a/extra/alarms/alarms-docs.factor b/extra/alarms/alarms-docs.factor index fcb2de8b6b..80a0c14079 100755 --- a/extra/alarms/alarms-docs.factor +++ b/extra/alarms/alarms-docs.factor @@ -9,7 +9,7 @@ HELP: add-alarm { $description "Creates and registers an alarm. If " { $snippet "frequency" } " is " { $link f } ", this will be a one-time alarm, otherwise it will fire with the given frequency. The quotation will be called from the alarm thread." } ; HELP: later -{ $values { "quot" quotation } { "time" duration } { "alarm" alarm } } +{ $values { "quot" quotation } { "dt" duration } { "alarm" alarm } } { $description "Creates and registers an alarm which calls the quotation once at " { $snippet "time" } { $link from-now } "." } ; HELP: cancel-alarm diff --git a/extra/combinators/lib/lib-docs.factor b/extra/combinators/lib/lib-docs.factor index d850243bd0..c88ce8d9f9 100755 --- a/extra/combinators/lib/lib-docs.factor +++ b/extra/combinators/lib/lib-docs.factor @@ -7,7 +7,7 @@ HELP: generate { $description "Loop until the generator quotation generates an object that satisfies predicate quotation." } { $unchecked-example "! Generate a random 20-bit prime number congruent to 3 (mod 4)" - "USE: math.miller-rabin" + "USING: combinators.lib math math.miller-rabin prettyprint ;" "[ 20 random-prime ] [ 4 mod 3 = ] generate ." "526367" } ; @@ -20,8 +20,8 @@ HELP: ndip "stack. The quotation can consume and produce any number of items." } { $examples - { $example "USE: combinators.lib" "1 2 [ dup ] 1 ndip .s" "1\n1\n2" } - { $example "USE: combinators.lib" "1 2 3 [ drop ] 2 ndip .s" "2\n3" } + { $example "USING: combinators.lib kernel prettyprint ;" "1 2 [ dup ] 1 ndip .s" "1\n1\n2" } + { $example "USING: combinators.lib kernel prettyprint ;" "1 2 3 [ drop ] 2 ndip .s" "2\n3" } } { $see-also dip dipd } ; @@ -32,7 +32,7 @@ HELP: nslip "removed from the stack, the quotation called, and the items restored." } { $examples - { $example "USE: combinators.lib" "[ 99 ] 1 2 3 4 5 5 nslip .s" "99\n1\n2\n3\n4\n5" } + { $example "USING: combinators.lib prettyprint ;" "[ 99 ] 1 2 3 4 5 5 nslip .s" "99\n1\n2\n3\n4\n5" } } { $see-also slip nkeep } ; @@ -43,7 +43,7 @@ HELP: nkeep "saved, the quotation called, and the items restored." } { $examples - { $example "USE: combinators.lib" "1 2 3 4 5 [ drop drop drop drop drop 99 ] 5 nkeep .s" "99\n1\n2\n3\n4\n5" } + { $example "USING: combinators.lib kernel prettyprint ;" "1 2 3 4 5 [ drop drop drop drop drop 99 ] 5 nkeep .s" "99\n1\n2\n3\n4\n5" } } { $see-also keep nslip } ; diff --git a/extra/concurrency/distributed/distributed-docs.factor b/extra/concurrency/distributed/distributed-docs.factor index 4fae6ddbcc..b3f3b633cd 100755 --- a/extra/concurrency/distributed/distributed-docs.factor +++ b/extra/concurrency/distributed/distributed-docs.factor @@ -2,9 +2,7 @@ USING: help.markup help.syntax concurrency.messaging threads ; IN: concurrency.distributed HELP: local-node -{ $values { "addrspec" "an address specifier" } -} -{ $description "Return the node the current thread is running on." } ; +{ $var-description "A variable containing the node the current thread is running on." } ; HELP: start-node { $values { "port" "a port number between 0 and 65535" } } diff --git a/extra/concurrency/distributed/distributed.factor b/extra/concurrency/distributed/distributed.factor index f09c441d26..4c5816b6cf 100755 --- a/extra/concurrency/distributed/distributed.factor +++ b/extra/concurrency/distributed/distributed.factor @@ -6,7 +6,7 @@ namespaces kernel io.encodings.binary ; QUALIFIED: io.sockets IN: concurrency.distributed -SYMBOL: local-node ( -- addrspec ) +SYMBOL: local-node : handle-node-client ( -- ) deserialize first2 get-process send ; diff --git a/extra/concurrency/locks/locks-docs.factor b/extra/concurrency/locks/locks-docs.factor index 3a89af5ba0..a3cf2fc782 100755 --- a/extra/concurrency/locks/locks-docs.factor +++ b/extra/concurrency/locks/locks-docs.factor @@ -1,4 +1,5 @@ -USING: help.markup help.syntax sequences kernel quotations ; +USING: help.markup help.syntax sequences kernel quotations +calendar ; IN: concurrency.locks HELP: lock @@ -12,11 +13,15 @@ HELP: { $values { "lock" lock } } { $description "Creates a reentrant lock." } ; -HELP: with-lock -{ $values { "lock" lock } { "timeout" "a timeout in milliseconds or " { $link f } } { "quot" quotation } } +HELP: with-lock-timeout +{ $values { "lock" lock } { "timeout" "a " { $link duration } " or " { $link f } } { "quot" quotation } } { $description "Calls the quotation, ensuring that only one thread executes with the lock held at a time. If another thread is holding the lock, blocks until the thread releases the lock." } { $errors "Throws an error if the lock could not be acquired before the timeout expires. A timeout value of " { $link f } " means the thread is willing to wait indefinitely." } ; +HELP: with-lock +{ $values { "lock" lock } { "quot" quotation } } +{ $description "Calls the quotation, ensuring that only one thread executes with the lock held at a time. If another thread is holding the lock, blocks until the thread releases the lock." } ; + ARTICLE: "concurrency.locks.mutex" "Mutual-exclusion locks" "A mutual-exclusion lock ensures that only one thread executes with the lock held at a time. They are used to protect critical sections so that certain operations appear to be atomic to other threads." $nl @@ -24,21 +29,30 @@ $nl { $subsection lock } { $subsection } { $subsection } -{ $subsection with-lock } ; +{ $subsection with-lock } +{ $subsection with-lock-timeout } ; HELP: rw-lock { $class-description "The class of reader/writer locks." } ; -HELP: with-read-lock -{ $values { "lock" lock } { "timeout" "a timeout in milliseconds or " { $link f } } { "quot" quotation } } +HELP: with-read-lock-timeout +{ $values { "lock" lock } { "timeout" "a " { $link duration } " or " { $link f } } { "quot" quotation } } { $description "Calls the quotation, ensuring that no other thread is holding a write lock at the same time. If another thread is holding a write lock, blocks until the thread releases the lock." } { $errors "Throws an error if the lock could not be acquired before the timeout expires. A timeout value of " { $link f } " means the thread is willing to wait indefinitely." } ; -HELP: with-write-lock -{ $values { "lock" lock } { "timeout" "a timeout in milliseconds or " { $link f } } { "quot" quotation } } +HELP: with-read-lock +{ $values { "lock" lock } { "quot" quotation } } +{ $description "Calls the quotation, ensuring that no other thread is holding a write lock at the same time. If another thread is holding a write lock, blocks until the thread releases the lock." } ; + +HELP: with-write-lock-timeout +{ $values { "lock" lock } { "timeout" "a " { $link duration } " or " { $link f } } { "quot" quotation } } { $description "Calls the quotation, ensuring that no other thread is holding a read or write lock at the same time. If another thread is holding a read or write lock, blocks until the thread releases the lock." } { $errors "Throws an error if the lock could not be acquired before the timeout expires. A timeout value of " { $link f } " means the thread is willing to wait indefinitely." } ; +HELP: with-write-lock +{ $values { "lock" lock } { "quot" quotation } } +{ $description "Calls the quotation, ensuring that no other thread is holding a read or write lock at the same time. If another thread is holding a read or write lock, blocks until the thread releases the lock." } ; + ARTICLE: "concurrency.locks.rw" "Read-write locks" "A read-write lock encapsulates a common pattern in the implementation of concurrent data structures, where one wishes to ensure that a thread is able to see a consistent view of the structure for a period of time, during which no other thread modifies the structure." $nl @@ -50,7 +64,10 @@ $nl { $subsection rw-lock } { $subsection } { $subsection with-read-lock } -{ $subsection with-write-lock } ; +{ $subsection with-write-lock } +"Versions of the above that take a timeout duration:" +{ $subsection with-read-lock-timeout } +{ $subsection with-write-lock-timeout } ; ARTICLE: "concurrency.locks" "Locks" "A " { $emphasis "lock" } " is an object protecting a critical region of code, enforcing a particular mutual-exclusion policy. The " { $vocab-link "concurrency.locks" } " vocabulary implements two types of locks:" diff --git a/extra/concurrency/messaging/messaging-docs.factor b/extra/concurrency/messaging/messaging-docs.factor index bee80fd357..e7aa5d1a7e 100755 --- a/extra/concurrency/messaging/messaging-docs.factor +++ b/extra/concurrency/messaging/messaging-docs.factor @@ -1,12 +1,12 @@ ! Copyright (C) 2006 Chris Double. ! See http://factorcode.org/license.txt for BSD license. USING: help.syntax help.markup concurrency.messaging.private -threads kernel arrays quotations ; +threads kernel arrays quotations threads strings ; IN: concurrency.messaging HELP: send { $values { "message" object } - { "thread" "a thread object" } + { "thread" thread } } { $description "Send the message to the thread by placing it in the threades mailbox. This is an asynchronous operation and will return immediately. The receving thread will act on the message the next time it retrieves that item from its mailbox (usually using the " { $link receive } " word. The message can be any Factor object. For destinations that are instances of remote-thread the message must be a serializable Factor type." } { $see-also receive receive-if } ; @@ -26,7 +26,8 @@ HELP: receive-if HELP: spawn-linked { $values { "quot" quotation } - { "thread" "a thread object" } + { "name" string } + { "thread" thread } } { $description "Start a thread which runs the given quotation. If that quotation throws an error which is not caught then the error will get propagated to the thread that spawned it. This can be used to set up 'supervisor' threades that restart child threades that crash due to uncaught errors.\n" } { $see-also spawn } ; diff --git a/extra/concurrency/messaging/messaging.factor b/extra/concurrency/messaging/messaging.factor index 6915653eb4..cfa2aea30d 100755 --- a/extra/concurrency/messaging/messaging.factor +++ b/extra/concurrency/messaging/messaging.factor @@ -7,7 +7,7 @@ USING: kernel threads concurrency.mailboxes continuations namespaces assocs random ; IN: concurrency.messaging -GENERIC: send ( message process -- ) +GENERIC: send ( message thread -- ) : mailbox-of ( thread -- mailbox ) dup thread-mailbox [ ] [ diff --git a/extra/concurrency/promises/promises-docs.factor b/extra/concurrency/promises/promises-docs.factor index a4d79d8a47..6a4a2bf8d6 100755 --- a/extra/concurrency/promises/promises-docs.factor +++ b/extra/concurrency/promises/promises-docs.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2005, 2008 Chris Double, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: concurrency.messaging kernel arrays -continuations help.markup help.syntax quotations ; +continuations help.markup help.syntax quotations calendar ; IN: concurrency.promises HELP: promise @@ -12,12 +12,12 @@ HELP: promise-fulfilled? { $description "Tests if " { $link fulfill } " has previously been called on the promise, in which case " { $link ?promise } " will return immediately without blocking." } ; HELP: ?promise-timeout -{ $values { "promise" promise } { "timeout" "a timeout in milliseconds or " { $link f } } { "value" object } } +{ $values { "promise" promise } { "timeout" "a " { $link duration } " or " { $link f } } { "result" object } } { $description "Waits for another thread to fulfill a promise, returning immediately if the promise has already been fulfilled. A timeout of " { $link f } " indicates that the thread may block indefinitely, otherwise it will wait up to " { $snippet "timeout" } " milliseconds." } { $errors "Throws an error if the timeout expires before the promise has been fulfilled." } ; HELP: ?promise -{ $values { "promise" promise } { "value" object } } +{ $values { "promise" promise } { "result" object } } { $description "Waits for another thread to fulfill a promise, returning immediately if the promise has already been fulfilled." } ; HELP: fulfill diff --git a/extra/concurrency/semaphores/semaphores-docs.factor b/extra/concurrency/semaphores/semaphores-docs.factor index 76a87f2077..33f4de8783 100755 --- a/extra/concurrency/semaphores/semaphores-docs.factor +++ b/extra/concurrency/semaphores/semaphores-docs.factor @@ -9,12 +9,12 @@ HELP: { $description "Creates a counting semaphore with the specified initial count." } ; HELP: acquire-timeout -{ $values { "semaphore" semaphore } { "timeout" "a " { $link duration } " or " { $link f } } { "value" object } } +{ $values { "semaphore" semaphore } { "timeout" "a " { $link duration } " or " { $link f } } } { $description "If the semaphore has a non-zero count, decrements it and returns immediately. Otherwise, if the timeout is " { $link f } ", waits indefinitely for the semaphore to be released. If the timeout is not " { $link f } ", waits a certain period of time, and if the semaphore still has not been released, throws an error." } { $errors "Throws an error if the timeout expires before the semaphore is released." } ; HELP: acquire -{ $values { "semaphore" semaphore } { "value" object } } +{ $values { "semaphore" semaphore } } { $description "If the semaphore has a non-zero count, decrements it and returns immediately. Otherwise, waits for it to be released." } ; HELP: release diff --git a/extra/crypto/common/common-docs.factor b/extra/crypto/common/common-docs.factor index 032e174eb1..b53ecaac3c 100644 --- a/extra/crypto/common/common-docs.factor +++ b/extra/crypto/common/common-docs.factor @@ -3,19 +3,19 @@ math.private ; IN: crypto.common HELP: >32-bit -{ $values { "x" "an integer" } { "y" "an integer" } } +{ $values { "x" integer } { "y" integer } } { $description "Used to implement 32-bit integer overflow." } ; HELP: >64-bit -{ $values { "x" "an integer" } { "y" "an integer" } } +{ $values { "x" integer } { "y" integer } } { $description "Used to implement 64-bit integer overflow." } ; HELP: bitroll -{ $values { "x" "an integer (input)" } { "s" "an integer (shift)" } { "w" "an integer (wrap)" } { "y" "an integer" } } +{ $values { "x" "an integer (input)" } { "s" "an integer (shift)" } { "w" "an integer (wrap)" } { "y" integer } } { $description "Roll n by s bits to the left, wrapping around after w bits." } { $examples - { $example "USE: crypto.common" "1 -1 32 bitroll .b" "10000000000000000000000000000000" } - { $example "USE: crypto.common" "HEX: ffff0000 8 32 bitroll .h" "ff0000ff" } + { $example "USING: crypto.common prettyprint ;" "1 -1 32 bitroll .b" "10000000000000000000000000000000" } + { $example "USING: crypto.common prettyprint ;" "HEX: ffff0000 8 32 bitroll .h" "ff0000ff" } } ; @@ -23,7 +23,7 @@ HELP: hex-string { $values { "seq" "a sequence" } { "str" "a string" } } { $description "Converts a sequence of values from 0-255 to a string of hex numbers from 0-ff." } { $examples - { $example "USE: crypto.common" "B{ 1 2 3 4 } hex-string print" "01020304" } + { $example "USING: crypto.common io ;" "B{ 1 2 3 4 } hex-string print" "01020304" } } { $notes "Numbers are zero-padded on the left." } ; diff --git a/extra/db/sql/sql-tests.factor b/extra/db/sql/sql-tests.factor index 2133b0e36c..c490ace770 100644 --- a/extra/db/sql/sql-tests.factor +++ b/extra/db/sql/sql-tests.factor @@ -1,4 +1,4 @@ -USING: kernel db.sql ; +USING: kernel namespaces db.sql sequences math ; IN: db.sql.tests TUPLE: person name age ; diff --git a/extra/farkup/farkup-docs.factor b/extra/farkup/farkup-docs.factor index 5d59a093af..b2b662db82 100644 --- a/extra/farkup/farkup-docs.factor +++ b/extra/farkup/farkup-docs.factor @@ -1,6 +1,6 @@ USING: help.markup help.syntax ; IN: farkup -HELP: parse-farkup +HELP: convert-farkup { $values { "string" "a string" } { "string'" "a string" } } { $description "Parse a string as farkup (Factor mARKUP) and output the result aas an string of HTML." } ; diff --git a/extra/help/crossref/crossref-docs.factor b/extra/help/crossref/crossref-docs.factor index 5c1f687d05..4331a45490 100644 --- a/extra/help/crossref/crossref-docs.factor +++ b/extra/help/crossref/crossref-docs.factor @@ -1,4 +1,5 @@ -USING: help.crossref help.topics help.syntax help.markup ; +USING: help.topics help.syntax help.markup ; +IN: help.crossref HELP: article-children { $values { "topic" "an article name or a word" } { "seq" "a new sequence" } } @@ -12,7 +13,7 @@ HELP: help-path { $values { "topic" "an article name or a word" } { "seq" "a new sequence" } } { $description "Outputs a sequence of all help articles which contain " { $snippet "topic" } " as a subsection, traversing all the way up to the root." } { $examples - { $example "USE: help.crossref" "\"sequences\" help-path ." "{ \"collections\" \"handbook\" }" } + { $example "USING: help.crossref prettyprint ;" "\"sequences\" help-path ." "{ \"collections\" \"handbook\" }" } } ; HELP: xref-article diff --git a/extra/help/handbook/handbook-tests.factor b/extra/help/handbook/handbook-tests.factor new file mode 100644 index 0000000000..ae6c7d55f4 --- /dev/null +++ b/extra/help/handbook/handbook-tests.factor @@ -0,0 +1,8 @@ +IN: help.handbook.tests +USING: help tools.test ; + +[ ] [ "article-index" help ] unit-test +[ ] [ "primitive-index" help ] unit-test +[ ] [ "error-index" help ] unit-test +[ ] [ "type-index" help ] unit-test +[ ] [ "class-index" help ] unit-test diff --git a/extra/help/help-docs.factor b/extra/help/help-docs.factor index fc795572fb..7318e8ed86 100755 --- a/extra/help/help-docs.factor +++ b/extra/help/help-docs.factor @@ -230,17 +230,17 @@ HELP: $examples { $values { "element" "a markup element" } } { $description "Prints a heading followed by some examples. Word documentation should include examples, at least if the usage of the word is not entirely obvious." } { $examples - { $markup-example { $examples { $example "2 2 + ." "4" } } } + { $markup-example { $examples { $example "USING: math prettyprint ;" "2 2 + ." "4" } } } } ; HELP: $example { $values { "element" "a markup element of the form " { $snippet "{ inputs... output }" } } } { $description "Prints a clickable example with sample output. The markup element must be an array of strings. All but the last string are joined by newlines and taken as the input text, and the last string is the output. The example becomes clickable if the output stream supports it, and clicking it opens a listener window with the input text inserted at the input prompt." } { $examples - "The output text should be a string of what the input prints when executed, not the final stack contents or anything like that. So the following is an incorrect example:" + "The input text must contain a correct " { $link POSTPONE: USING: } " declaration, and output text should be a string of what the input prints when executed, not the final stack contents or anything like that. So the following is an incorrect example:" { $markup-example { $unchecked-example "2 2 +" "4" } } "However the following is right:" - { $markup-example { $example "2 2 + ." "4" } } + { $markup-example { $example "USING: math prettyprint ;" "2 2 + ." "4" } } "Examples can incorporate a call to " { $link .s } " to show multiple output values; the convention is that you may assume the stack is empty before the example evaluates." } ; @@ -270,7 +270,7 @@ HELP: textual-list { $values { "seq" "a sequence" } { "quot" "a quotation with stack effect " { $snippet "( elt -- )" } } } { $description "Applies the quotation to each element of the sequence, printing a comma between each pair of elements." } { $examples - { $example "USE: help.markup" "{ \"fish\" \"chips\" \"salt\" } [ write ] textual-list" "fish, chips, salt" } + { $example "USING: help.markup io ;" "{ \"fish\" \"chips\" \"salt\" } [ write ] textual-list" "fish, chips, salt" } } ; HELP: $links diff --git a/extra/help/help.factor b/extra/help/help.factor index 9332e6aff8..85f5a35a5c 100755 --- a/extra/help/help.factor +++ b/extra/help/help.factor @@ -109,9 +109,7 @@ M: word set-article-parent swap "help-parent" set-word-prop ; ] ?if ; : ($index) ( articles -- ) - subsection-style get [ - sort-articles [ nl ] [ ($subsection) ] interleave - ] with-style ; + sort-articles [ \ $subsection swap 2array ] map print-element ; : $index ( element -- ) first call dup empty? diff --git a/extra/help/lint/lint-docs.factor b/extra/help/lint/lint-docs.factor index 6aa3310bf9..0c0fcf92d2 100644 --- a/extra/help/lint/lint-docs.factor +++ b/extra/help/lint/lint-docs.factor @@ -5,7 +5,7 @@ HELP: help-lint-all { $description "Checks all word help and articles in all loaded vocabularies." } ; HELP: help-lint -{ $values { "vocab" "a vocabulary specifier" } } +{ $values { "prefix" "a vocabulary specifier" } } { $description "Checks all word help and articles in the given vocabulary and all child vocabularies." } ; ARTICLE: "help.lint" "Help lint tool" diff --git a/extra/help/lint/lint.factor b/extra/help/lint/lint.factor index 4b97499a4c..22a1945b24 100644 --- a/extra/help/lint/lint.factor +++ b/extra/help/lint/lint.factor @@ -5,7 +5,7 @@ words strings classes tools.browser namespaces io io.streams.string prettyprint definitions arrays vectors combinators splitting debugger hashtables sorting effects vocabs vocabs.loader assocs editors continuations classes.predicate -macros combinators.lib sequences.lib ; +macros combinators.lib sequences.lib math ; IN: help.lint : check-example ( element -- ) @@ -27,8 +27,13 @@ IN: help.lint ] unless ; : effect-values ( word -- seq ) - stack-effect dup effect-in swap effect-out - append [ string? ] subset prune natural-sort ; + stack-effect dup effect-in swap effect-out append [ + { + { [ dup word? ] [ word-name ] } + { [ dup integer? ] [ drop "object" ] } + { [ dup string? ] [ ] } + } cond + ] map prune natural-sort ; : contains-funky-elements? ( element -- ? ) { diff --git a/extra/io/buffers/buffers-docs.factor b/extra/io/buffers/buffers-docs.factor index dbd05eaf2f..5ce9b71427 100755 --- a/extra/io/buffers/buffers-docs.factor +++ b/extra/io/buffers/buffers-docs.factor @@ -115,11 +115,11 @@ HELP: n>buffer { $errors "Throws an error if the buffer does not contain " { $snippet "n" } " bytes of data." } ; HELP: buffer-peek -{ $values { "buffer" buffer } { "ch" "a character" } } +{ $values { "buffer" buffer } { "byte" "a byte" } } { $description "Outputs the byte at the buffer position." } ; HELP: buffer-pop -{ $values { "buffer" buffer } { "ch" "a character" } } +{ $values { "buffer" buffer } { "byte" "a byte" } } { $description "Outputs the byte at the buffer position and advances the position." } ; HELP: buffer-until diff --git a/extra/io/buffers/buffers.factor b/extra/io/buffers/buffers.factor index a2ecfe3f3e..7d51d04d7b 100755 --- a/extra/io/buffers/buffers.factor +++ b/extra/io/buffers/buffers.factor @@ -31,10 +31,10 @@ TUPLE: buffer size ptr fill pos ; : buffer-end ( buffer -- alien ) dup buffer-fill swap buffer-ptr ; -: buffer-peek ( buffer -- ch ) +: buffer-peek ( buffer -- byte ) buffer@ 0 alien-unsigned-1 ; -: buffer-pop ( buffer -- ch ) +: buffer-pop ( buffer -- byte ) dup buffer-peek 1 rot buffer-consume ; : (buffer>) ( n buffer -- byte-array ) @@ -90,7 +90,7 @@ HINTS: search-buffer-until { fixnum fixnum simple-alien string } ; [ buffer-end byte-array>memory ] 2keep [ buffer-fill swap length + ] keep set-buffer-fill ; -: byte>buffer ( ch buffer -- ) +: byte>buffer ( byte buffer -- ) 1 over check-overflow [ buffer-end 0 set-alien-unsigned-1 ] keep [ buffer-fill 1+ ] keep set-buffer-fill ; diff --git a/extra/io/launcher/launcher-docs.factor b/extra/io/launcher/launcher-docs.factor index 01da3bf64f..7fdd22c8a5 100755 --- a/extra/io/launcher/launcher-docs.factor +++ b/extra/io/launcher/launcher-docs.factor @@ -75,8 +75,8 @@ HELP: current-process-handle { $description "Returns the handle of the current process." } ; HELP: run-process* -{ $values { "desc" "a launch descriptor" } { "handle" "a process handle" } } -{ $contract "Launches a process using the launch descriptor." } +{ $values { "process" process } { "handle" "a process handle" } } +{ $contract "Launches a process." } { $notes "User code should call " { $link run-process } " instead." } ; HELP: run-process diff --git a/extra/io/launcher/launcher.factor b/extra/io/launcher/launcher.factor index 08f5160a61..e133416101 100755 --- a/extra/io/launcher/launcher.factor +++ b/extra/io/launcher/launcher.factor @@ -115,7 +115,7 @@ TUPLE: process-failed code ; : process-failed ( code -- * ) \ process-failed construct-boa throw ; -: try-process ( command/process -- ) +: try-process ( desc -- ) run-process wait-for-process dup zero? [ drop ] [ process-failed ] if ; diff --git a/extra/io/monitors/monitors-docs.factor b/extra/io/monitors/monitors-docs.factor index 9d985ff3fb..76a354b0bd 100755 --- a/extra/io/monitors/monitors-docs.factor +++ b/extra/io/monitors/monitors-docs.factor @@ -2,13 +2,13 @@ IN: io.monitors USING: help.markup help.syntax continuations ; HELP: -{ $values { "path" "a pathname string" } { "recursive?" "a boolean" } } +{ $values { "path" "a pathname string" } { "recursive?" "a boolean" } { "monitor" "a new monitor" } } { $description "Opens a file system change monitor which listens for changes on " { $snippet "path" } ". The boolean indicates whether changes in subdirectories should be reported." $nl "Not all operating systems support recursive monitors; if recursive monitoring is not available, an error is thrown and the caller must implement alternative logic for monitoring subdirectories." } ; HELP: next-change -{ $values { "monitor" "a monitor" } { "path" "a pathname string" } { "changes" "a change descriptor" } } +{ $values { "monitor" "a monitor" } { "path" "a pathname string" } { "changed" "a change descriptor" } } { $description "Waits for file system changes and outputs the pathname of the first changed file. The change descriptor is aq sequence of symbols documented in " { $link "io.monitors.descriptors" } "." } ; HELP: with-monitor diff --git a/extra/io/nonblocking/nonblocking-docs.factor b/extra/io/nonblocking/nonblocking-docs.factor index e1cb6425ff..ae69553b53 100755 --- a/extra/io/nonblocking/nonblocking-docs.factor +++ b/extra/io/nonblocking/nonblocking-docs.factor @@ -58,17 +58,17 @@ HELP: $low-level-note ; HELP: -{ $values { "handle" "a native handle identifying an I/O resource" } { "port" "a new " { $link port } } } +{ $values { "handle" "a native handle identifying an I/O resource" } { "type" symbol } { "port" "a new " { $link port } } } { $description "Creates a new " { $link port } " using the specified native handle and a default-sized I/O buffer." } $low-level-note ; HELP: -{ $values { "handle" "a native handle identifying an I/O resource" } { "stream" "a new " { $link input-port } } } +{ $values { "handle" "a native handle identifying an I/O resource" } { "input-port" "a new " { $link input-port } } } { $description "Creates a new " { $link input-port } " using the specified native handle and a default-sized input buffer." } $low-level-note ; HELP: -{ $values { "handle" "a native handle identifying an I/O resource" } { "stream" "a new " { $link output-port } } } +{ $values { "handle" "a native handle identifying an I/O resource" } { "output-port" "a new " { $link output-port } } } { $description "Creates a new " { $link output-port } " using the specified native handle and a default-sized input buffer." } $low-level-note ; diff --git a/extra/io/nonblocking/nonblocking.factor b/extra/io/nonblocking/nonblocking.factor index 1cd8658355..8f5babeff7 100755 --- a/extra/io/nonblocking/nonblocking.factor +++ b/extra/io/nonblocking/nonblocking.factor @@ -109,7 +109,7 @@ M: input-port stream-read buffer-until ] if ; -: read-until-loop ( seps port byte-vector -- separator/f ) +: read-until-loop ( seps port accum -- separator/f ) 2over read-until-step over [ >r over push-all r> dup [ >r 3drop r> @@ -125,7 +125,7 @@ M: input-port stream-read-until ( seps port -- byte-array/f sep/f ) >r 2nip r> ] [ over [ - drop >byte-vector + drop BV{ } like [ read-until-loop ] keep B{ } like swap ] [ diff --git a/extra/io/server/server-docs.factor b/extra/io/server/server-docs.factor index cbcaae9569..7eda48f747 100755 --- a/extra/io/server/server-docs.factor +++ b/extra/io/server/server-docs.factor @@ -2,7 +2,7 @@ USING: help help.syntax help.markup io ; IN: io.server HELP: with-server -{ $values { "seq" "a sequence of address specifiers" } { "service" "a string or " { $link f } } { "quot" "a quotation" } } +{ $values { "seq" "a sequence of address specifiers" } { "service" "a string or " { $link f } } { "encoding" "an encoding to use for client connections" } { "quot" "a quotation" } } { $description "Starts a TCP/IP server. The quotation is called in a new thread for each client connection, with the client connection being the " { $link stdio } " stream. Client connections are logged to the " { $link stdio } " stream at the time the server was started." } ; HELP: with-datagrams diff --git a/extra/lazy-lists/lazy-lists-docs.factor b/extra/lazy-lists/lazy-lists-docs.factor index 11afc9b6b5..ebacea03d8 100644 --- a/extra/lazy-lists/lazy-lists-docs.factor +++ b/extra/lazy-lists/lazy-lists-docs.factor @@ -26,7 +26,7 @@ HELP: nil? { $values { "cons" "a cons object" } { "?" "a boolean" } } { $description "Return true if the cons object is the nil cons." } ; -HELP: list? +HELP: list? ( object -- ? ) { $values { "object" "an object" } { "?" "a boolean" } } { $description "Returns true if the object conforms to the list protocol." } ; @@ -175,7 +175,7 @@ HELP: lmerge { $values { "list1" "a list" } { "list2" "a list" } { "result" "lazy list merging list1 and list2" } } { $description "Return the result of merging the two lists in a lazy manner." } { $examples - { $example "USE: lazy-lists" "{ 1 2 3 } >list { 4 5 6 } >list lmerge list>array ." "{ 1 4 2 5 3 6 }" } + { $example "USING: lazy-lists prettyprint ;" "{ 1 2 3 } >list { 4 5 6 } >list lmerge list>array ." "{ 1 4 2 5 3 6 }" } } ; HELP: lcontents diff --git a/extra/lazy-lists/lazy-lists-tests.factor b/extra/lazy-lists/lazy-lists-tests.factor index 0424a5d069..302299b452 100644 --- a/extra/lazy-lists/lazy-lists-tests.factor +++ b/extra/lazy-lists/lazy-lists-tests.factor @@ -23,3 +23,7 @@ IN: lazy-lists.tests [ { 5 6 7 8 } ] [ { 1 2 3 } >list { 4 5 } >list 2list { [ first odd? ] } [ first2 + ] lcomp* list>array ] unit-test + +[ { 4 5 6 } ] [ + 3 { 1 2 3 } >list [ + ] lmap-with list>array +] unit-test diff --git a/extra/lazy-lists/lazy-lists.factor b/extra/lazy-lists/lazy-lists.factor index e3e7b14917..07cd34b4df 100644 --- a/extra/lazy-lists/lazy-lists.factor +++ b/extra/lazy-lists/lazy-lists.factor @@ -144,25 +144,8 @@ M: lazy-map cdr ( lazy-map -- cdr ) M: lazy-map nil? ( lazy-map -- bool ) lazy-map-cons nil? ; -TUPLE: lazy-map-with value cons quot ; - -C: lazy-map-with - : lmap-with ( value list quot -- result ) - over nil? [ 3drop nil ] [ ] if ; - -M: lazy-map-with car ( lazy-map-with -- car ) - [ lazy-map-with-value ] keep - [ lazy-map-with-cons car ] keep - lazy-map-with-quot call ; - -M: lazy-map-with cdr ( lazy-map-with -- cdr ) - [ lazy-map-with-value ] keep - [ lazy-map-with-cons cdr ] keep - lazy-map-with-quot lmap-with ; - -M: lazy-map-with nil? ( lazy-map-with -- bool ) - lazy-map-with-cons nil? ; + with lmap ; TUPLE: lazy-take n cons ; @@ -453,7 +436,6 @@ INSTANCE: lazy-io list INSTANCE: lazy-concat list INSTANCE: lazy-cons list INSTANCE: lazy-map list -INSTANCE: lazy-map-with list INSTANCE: lazy-take list INSTANCE: lazy-append list INSTANCE: lazy-from-by list diff --git a/extra/locals/locals-docs.factor b/extra/locals/locals-docs.factor index b8d836ecc1..62f2eac513 100644 --- a/extra/locals/locals-docs.factor +++ b/extra/locals/locals-docs.factor @@ -15,7 +15,7 @@ HELP: [| { $description "A lambda abstraction. When called, reads stack values into the bindings from left to right; the body may then refer to these bindings." } { $examples { $example - "USE: locals" + "USING: kernel locals math prettyprint ;" ":: adder ( n -- quot ) [| m | m n + ] ;" "3 5 adder call ." "8" @@ -28,7 +28,7 @@ HELP: [let { $description "Introduces a set of lexical bindings and evaluates the body. The values are evaluated in parallel, and may not refer to other bindings within the same " { $link POSTPONE: [let } " form; for Lisp programmers, this means that Factor's " { $link POSTPONE: [let } " is equivalent to the Lisp " { $snippet "let" } ", not " { $snippet "let*" } "." } { $examples { $example - "USING: locals math.functions ;" + "USING: kernel locals math math.functions prettyprint sequences ;" ":: frobnicate ( n seq -- newseq )" " [let | n' [ n 6 * ] |" " seq [ n' gcd nip ] map ] ;" @@ -43,7 +43,7 @@ HELP: [wlet { $description "Introduces a set of lexically-scoped non-recursive local functions. The bodies may not refer to other bindings within the same " { $link POSTPONE: [wlet } " form; for Lisp programmers, this means that Factor's " { $link POSTPONE: [wlet } " is equivalent to the Lisp " { $snippet "flet" } ", not " { $snippet "labels" } "." } { $examples { $example - "USE: locals" + "USING: locals math prettyprint sequences ;" ":: quuxify ( n seq -- newseq )" " [wlet | add-n [| m | m n + ] |" " seq [ add-n ] map ] ;" diff --git a/extra/logging/analysis/analysis-docs.factor b/extra/logging/analysis/analysis-docs.factor index 2919f2bcd4..10b6924b52 100644 --- a/extra/logging/analysis/analysis-docs.factor +++ b/extra/logging/analysis/analysis-docs.factor @@ -16,7 +16,7 @@ HELP: analysis. { $description "Prints a logging report output by " { $link analyze-entries } ". Formatted output words are used, so the report looks nice in the UI or if sent to an HTML stream." } ; HELP: analyze-log -{ $values { "service" "a log service name" } { "n" integer } { "word-names" "a sequence of strings" } } +{ $values { "lines" "a parsed log file" } { "word-names" "a sequence of strings" } } { $description "Analyzes a log file and prints a formatted report. The " { $snippet "word-names" } " parameter is documented in " { $link analyze-entries } "." } ; ARTICLE: "logging.analysis" "Log analysis" diff --git a/extra/logging/insomniac/insomniac-docs.factor b/extra/logging/insomniac/insomniac-docs.factor index 7529c3ba63..c86a675698 100755 --- a/extra/logging/insomniac/insomniac-docs.factor +++ b/extra/logging/insomniac/insomniac-docs.factor @@ -9,7 +9,7 @@ HELP: insomniac-recipients { $var-description "A sequence of e-mail addresses to mail log reports to. Must be set before " { $vocab-link "logging.insomniac" } " is used." } ; HELP: ?analyze-log -{ $values { "service" "a log service name" } { "word-names" "a sequence of strings" } { "string" string } } +{ $values { "service" "a log service name" } { "word-names" "a sequence of strings" } { "string/f" string } } { $description "Analyzes the most recent log and outputs the string analysis, or outputs " { $link f } " if it doesn't exist." } { $see-also analyze-log } ; @@ -18,7 +18,7 @@ HELP: email-log-report { $description "E-mails a log report for the given log service. The " { $link insomniac-sender } " and " { $link insomniac-recipients } " parameters must be set up first. The " { $snippet "word-names" } " parameter is documented in " { $link analyze-entries } "." } ; HELP: schedule-insomniac -{ $values { "alist" "a sequence of pairs of shape " { $snippet "{ service word-names }" } } } +{ $values { "service" "a log service name" } { "word-names" "a sequence of strings" } } { $description "Starts a thread which e-mails log reports and rotates logs daily." } ; ARTICLE: "logging.insomniac" "Automated log analysis" diff --git a/extra/logging/logging-docs.factor b/extra/logging/logging-docs.factor index a7750fe388..df0b132ac8 100755 --- a/extra/logging/logging-docs.factor +++ b/extra/logging/logging-docs.factor @@ -39,19 +39,19 @@ HELP: log-message { $description "Sends a message to the current log. Does nothing if not executing in a dynamic scope established by " { $link with-logging } "." } ; HELP: add-logging -{ $values { "word" word } } +{ $values { "level" "a log level" } { "word" word } } { $description "Causes the word to log a message every time it is called." } ; HELP: add-input-logging -{ $values { "word" word } } +{ $values { "level" "a log level" } { "word" word } } { $description "Causes the word to log its input values every time it is called. The word must have a stack effect declaration." } ; HELP: add-output-logging -{ $values { "word" word } } +{ $values { "level" "a log level" } { "word" word } } { $description "Causes the word to log its output values every time it is called. The word must have a stack effect declaration." } ; HELP: add-error-logging -{ $values { "word" word } } +{ $values { "level" "a log level" } { "word" word } } { $description "Causes the word to log its input values and any errors it throws." $nl "If the word is not executed in a dynamic scope established by " { $link with-logging } ", its behavior is unchanged, and any errors it throws are passed to the caller." @@ -63,7 +63,7 @@ HELP: log-error { $description "Logs an error." } ; HELP: log-critical -{ $values { "critical" "an critical" } { "word" word } } +{ $values { "error" "an error" } { "word" word } } { $description "Logs a critical error." } ; HELP: LOG: diff --git a/extra/logging/parser/parser-docs.factor b/extra/logging/parser/parser-docs.factor index ee995749be..dc80f9e87f 100644 --- a/extra/logging/parser/parser-docs.factor +++ b/extra/logging/parser/parser-docs.factor @@ -6,7 +6,7 @@ HELP: parse-log { $description "Parses a sequence of log entries. Malformed entries are printed out and ignore. The result is a sequence of arrays of the shape " { $snippet "{ timestamp level word-name message }" } ", where" { $list { { $snippet "timestamp" } " is a " { $link timestamp } } - { { $snippet "level" } " is a log level; see " { $link "logger.levels" } } + { { $snippet "level" } " is a log level; see " { $link "logging.levels" } } { { $snippet "word-name" } " is a string" } { { $snippet "message" } " is a string" } } diff --git a/extra/match/match-docs.factor b/extra/match/match-docs.factor index 96d2ea98de..4ac59bb0cc 100644 --- a/extra/match/match-docs.factor +++ b/extra/match/match-docs.factor @@ -41,7 +41,7 @@ HELP: match-replace { $description "Matches the " { $snippet "object" } " against " { $snippet "pattern1" } ". The pattern match variables in " { $snippet "pattern1" } " are assigned the values from the matching " { $snippet "object" } ". These are then replaced into the " { $snippet "pattern2" } " pattern match variables." } { $examples { $example - "USE: match" + "USING: match prettyprint ;" "MATCH-VARS: ?a ?b ;" "{ 1 2 } { ?a ?b } { ?b ?a } match-replace ." "{ 2 1 }" diff --git a/extra/math/combinatorics/combinatorics-docs.factor b/extra/math/combinatorics/combinatorics-docs.factor index c763cc32cf..355898a8bd 100644 --- a/extra/math/combinatorics/combinatorics-docs.factor +++ b/extra/math/combinatorics/combinatorics-docs.factor @@ -4,46 +4,46 @@ IN: math.combinatorics HELP: factorial { $values { "n" "a non-negative integer" } { "n!" integer } } { $description "Outputs the product of all positive integers less than or equal to " { $snippet "n" } "." } -{ $examples { $example "4 factorial ." "24" } } ; +{ $examples { $example "USING: math.combinatorics prettyprint ;" "4 factorial ." "24" } } ; HELP: nPk { $values { "n" "a non-negative integer" } { "k" "a non-negative integer" } { "nPk" integer } } { $description "Outputs the total number of unique permutations of size " { $snippet "k" } " (order does matter) that can be taken from a set of size " { $snippet "n" } "." } -{ $examples { $example "10 4 nPk ." "5040" } } ; +{ $examples { $example "USING: math.combinatorics prettyprint ;" "10 4 nPk ." "5040" } } ; HELP: nCk { $values { "n" "a non-negative integer" } { "k" "a non-negative integer" } { "nCk" integer } } { $description "Outputs the total number of unique combinations of size " { $snippet "k" } " (order does not matter) that can be taken from a set of size " { $snippet "n" } ". Commonly written as \"n choose k\"." } -{ $examples { $example "10 4 nCk ." "210" } } ; +{ $examples { $example "USING: math.combinatorics prettyprint ;" "10 4 nCk ." "210" } } ; HELP: permutation { $values { "n" "a non-negative integer" } { "seq" sequence } { "seq" sequence } } { $description "Outputs the " { $snippet "nth" } " lexicographical permutation of " { $snippet "seq" } "." } { $notes "Permutations are 0-based and a bounds error will be thrown if " { $snippet "n" } " is larger than " { $snippet "seq length factorial 1-" } "." } -{ $examples { $example "1 3 permutation ." "{ 0 2 1 }" } { $example "5 { \"apple\" \"banana\" \"orange\" } permutation ." "{ \"orange\" \"banana\" \"apple\"}" } } ; +{ $examples { $example "USING: math.combinatorics prettyprint ;" "1 3 permutation ." "{ 0 2 1 }" } { $example "USING: math.combinatorics prettyprint ;" "5 { \"apple\" \"banana\" \"orange\" } permutation ." "{ \"orange\" \"banana\" \"apple\" }" } } ; HELP: all-permutations { $values { "seq" sequence } { "seq" sequence } } { $description "Outputs a sequence containing all permutations of " { $snippet "seq" } " in lexicographical order." } -{ $examples { $example "3 all-permutations ." "{ { 0 1 2 } { 0 2 1 } { 1 0 2 } { 1 2 0 } { 2 0 1 } { 2 1 0 } }" } } ; +{ $examples { $example "USING: math.combinatorics prettyprint ;" "3 all-permutations ." "{ { 0 1 2 } { 0 2 1 } { 1 0 2 } { 1 2 0 } { 2 0 1 } { 2 1 0 } }" } } ; HELP: inverse-permutation { $values { "seq" sequence } { "permutation" sequence } } { $description "Outputs a sequence of indices representing the lexicographical permutation of " { $snippet "seq" } "." } { $notes "All items in " { $snippet "seq" } " must be comparable by " { $link <=> } "." } -{ $examples { $example "\"dcba\" inverse-permutation ." "{ 3 2 1 0 }" } { $example "{ 12 56 34 78 } inverse-permutation ." "{ 0 2 1 3 }" } } ; +{ $examples { $example "USING: math.combinatorics prettyprint ;" "\"dcba\" inverse-permutation ." "{ 3 2 1 0 }" } { $example "USING: math.combinatorics prettyprint ;" "{ 12 56 34 78 } inverse-permutation ." "{ 0 2 1 3 }" } } ; IN: math.combinatorics.private HELP: factoradic -{ $values { "n" integer } { "seq" sequence } } +{ $values { "n" integer } { "factoradic" sequence } } { $description "Converts a positive integer " { $snippet "n" } " to factoradic form. The factoradic of an integer is its representation based on a mixed radix numerical system that corresponds to the values of " { $snippet "n" } " factorial." } -{ $examples { $example "859 factoradic ." "{ 1 1 0 3 0 1 0 }" } } ; +{ $examples { $example "USING: math.combinatorics.private prettyprint ;" "859 factoradic ." "{ 1 1 0 3 0 1 0 }" } } ; HELP: >permutation { $values { "factoradic" sequence } { "permutation" sequence } } { $description "Converts an integer represented in factoradic form into its corresponding unique permutation (0-based)." } { $notes "For clarification, the following two statements are equivalent:" { $code "10 factoradic >permutation" "{ 1 2 0 0 } >permutation" } } -{ $examples { $example "{ 0 0 0 0 } >permutation ." "{ 0 1 2 3 }" } } ; +{ $examples { $example "USING: math.combinatorics.private prettyprint ;" "{ 0 0 0 0 } >permutation ." "{ 0 1 2 3 }" } } ; diff --git a/extra/math/erato/erato-docs.factor b/extra/math/erato/erato-docs.factor index 6e84c84057..29bd3020f3 100644 --- a/extra/math/erato/erato-docs.factor +++ b/extra/math/erato/erato-docs.factor @@ -3,4 +3,4 @@ IN: math.erato HELP: lerato { $values { "n" "a positive number" } { "lazy-list" "a lazy prime numbers generator" } } -{ $description "Builds a lazy list containing the prime numbers between 2 and " { $snippet "n" } " (inclusive). Lazy lists are described in " { $link "lazy-lists" } "." } ; +{ $description "Builds a lazy list containing the prime numbers between 2 and " { $snippet "n" } " (inclusive)." } ; diff --git a/extra/math/functions/functions-docs.factor b/extra/math/functions/functions-docs.factor index d3a81566b9..f0819fb03e 100755 --- a/extra/math/functions/functions-docs.factor +++ b/extra/math/functions/functions-docs.factor @@ -273,16 +273,16 @@ HELP: mod-inv { $description "Outputs an integer " { $snippet "y" } " such that " { $snippet "xy = 1 (mod n)" } "." } { $errors "Throws an error if " { $snippet "n" } " is not invertible modulo " { $snippet "n" } "." } { $examples - { $example "USE: math.functions" "173 1119 mod-inv ." "815" } - { $example "USE: math.functions" "173 815 * 1119 mod ." "1" } + { $example "USING: math.functions prettyprint ;" "173 1119 mod-inv ." "815" } + { $example "USING: math prettyprint ;" "173 815 * 1119 mod ." "1" } } ; HELP: each-bit { $values { "n" integer } { "quot" "a quotation with stack effect " { $snippet "( ? -- )" } } } { $description "Applies the quotation to each bit of the integer, starting from the least significant bit, and stopping at the last bit from which point on all bits are either clear (if the integer is positive) or all bits are set (if the integer is negataive)." } { $examples - { $example "USE: math.functions" "[ BIN: 1101 [ , ] each-bit ] { } make ." "{ t f t t }" } - { $example "USE: math.functions" "[ -3 [ , ] each-bit ] { } make ." "{ t f }" } + { $example "USING: math.functions namespaces prettyprint ;" "[ BIN: 1101 [ , ] each-bit ] { } make ." "{ t f t t }" } + { $example "USING: math.functions namespaces prettyprint ;" "[ -3 [ , ] each-bit ] { } make ." "{ t f }" } } ; HELP: ~ diff --git a/extra/math/primes/factors/factors-docs.factor b/extra/math/primes/factors/factors-docs.factor index f5b14b5a5a..f9fe4d5dcb 100644 --- a/extra/math/primes/factors/factors-docs.factor +++ b/extra/math/primes/factors/factors-docs.factor @@ -6,17 +6,17 @@ IN: math.primes.factors HELP: factors { $values { "n" "a positive integer" } { "seq" sequence } } { $description { "Return an ordered list of a number's prime factors, possibly repeated." } } -{ $examples { $example "300 factors ." "{ 2 2 3 5 5 }" } } ; +{ $examples { $example "USING: math.primes.factors prettyprint ;" "300 factors ." "{ 2 2 3 5 5 }" } } ; HELP: group-factors { $values { "n" "a positive integer" } { "seq" sequence } } { $description { "Return a sequence of pairs representing each prime factor in the number and its corresponding power (multiplicity)." } } -{ $examples { $example "300 group-factors ." "{ { 2 2 } { 3 1 } { 5 2 } }" } } ; +{ $examples { $example "USING: math.primes.factors prettyprint ;" "300 group-factors ." "{ { 2 2 } { 3 1 } { 5 2 } }" } } ; HELP: unique-factors { $values { "n" "a positive integer" } { "seq" sequence } } { $description { "Return an ordered list of a number's unique prime factors." } } -{ $examples { $example "300 unique-factors ." "{ 2 3 5 }" } } ; +{ $examples { $example "USING: math.primes.factors prettyprint ;" "300 unique-factors ." "{ 2 3 5 }" } } ; HELP: totient { $values { "n" "a positive integer" } { "t" integer } } diff --git a/extra/math/statistics/statistics-docs.factor b/extra/math/statistics/statistics-docs.factor index 4787a85aed..695834b554 100644 --- a/extra/math/statistics/statistics-docs.factor +++ b/extra/math/statistics/statistics-docs.factor @@ -4,56 +4,56 @@ IN: math.statistics HELP: geometric-mean { $values { "seq" "a sequence of numbers" } { "n" "a non-negative real number"} } { $description "Computes the geometric mean of all elements in " { $snippet "seq" } ". The geometric mean measures the central tendency of a data set that minimizes the effects of extreme values." } -{ $examples { $example "USE: math.statistics" "{ 1 2 3 } geometric-mean ." "1.81712059283214" } } +{ $examples { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 } geometric-mean ." "1.81712059283214" } } { $errors "Throws a " { $link signal-error. } " (square-root of 0) if the sequence is empty." } ; HELP: harmonic-mean { $values { "seq" "a sequence of numbers" } { "n" "a non-negative real number"} } { $description "Computes the harmonic mean of the elements in " { $snippet "seq" } ". The harmonic mean is appropriate when the average of rates is desired." } -{ $examples { $example "USE: math.statistics" "{ 1 2 3 } harmonic-mean ." "6/11" } } +{ $examples { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 } harmonic-mean ." "6/11" } } { $errors "Throws a " { $link signal-error. } " (divide by zero) if the sequence is empty." } ; HELP: mean { $values { "seq" "a sequence of numbers" } { "n" "a non-negative real number"} } { $description "Computes the arithmetic mean of all elements in " { $snippet "seq" } "." } -{ $examples { $example "USE: math.statistics" "{ 1 2 3 } mean ." "2" } } +{ $examples { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 } mean ." "2" } } { $errors "Throws a " { $link signal-error. } " (divide by zero) if the sequence is empty." } ; HELP: median { $values { "seq" "a sequence of numbers" } { "n" "a non-negative real number"} } { $description "Computes the median of " { $snippet "seq" } " by sorting the sequence from lowest value to highest and outputting the middle one. If there is an even number of elements in the sequence, the median is not unique, so the mean of the two middle values is outputted." } { $examples - { $example "USE: math.statistics" "{ 1 2 3 } median ." "2" } - { $example "USE: math.statistics" "{ 1 2 3 4 } median ." "5/2" } } + { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 } median ." "2" } + { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 4 } median ." "2+1/2" } } { $errors "Throws a " { $link signal-error. } " (divide by zero) if the sequence is empty." } ; HELP: range { $values { "seq" "a sequence of numbers" } { "n" "a non-negative real number"} } { $description "Computes the distance of the maximum and minimum values in " { $snippet "seq" } "." } { $examples - { $example "USE: math.statistics" "{ 1 2 3 } range ." "2" } - { $example "USE: math.statistics" "{ 1 2 3 4 } range ." "3" } } ; + { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 } range ." "2" } + { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 4 } range ." "3" } } ; HELP: std { $values { "seq" "a sequence of numbers" } { "x" "a non-negative real number"} } { $description "Computes the standard deviation of " { $snippet "seq" } " by squaring the variance of the sequence. It measures how widely spread the values in a sequence are about the mean." } { $examples - { $example "USE: math.statistics" "{ 1 2 3 } std ." "1.0" } - { $example "USE: math.statistics" "{ 1 2 3 4 } std ." "1.290994448735806" } } ; + { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 } std ." "1.0" } + { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 4 } std ." "1.290994448735806" } } ; HELP: ste { $values { "seq" "a sequence of numbers" } { "x" "a non-negative real number"} } { $description "Computes the standard error of the mean for " { $snippet "seq" } ". It's defined as the standard deviation divided by the square root of the length of the sequence, and measures uncertainty associated with the estimate of the mean." } { $examples - { $example "USE: math.statistics" "{ -2 2 } ste ." "2.0" } - { $example "USE: math.statistics" "{ -2 2 2 } ste ." "1.333333333333333" } } ; + { $example "USING: math.statistics prettyprint ;" "{ -2 2 } ste ." "2.0" } + { $example "USING: math.statistics prettyprint ;" "{ -2 2 2 } ste ." "1.333333333333333" } } ; HELP: var { $values { "seq" "a sequence of numbers" } { "x" "a non-negative real number"} } { $description "Computes the variance of " { $snippet "seq" } ". It's a measurement of the spread of values in a sequence. The larger the variance, the larger the distance of values from the mean." } { $notes "If the number of elements in " { $snippet "seq" } " is 1 or less, it outputs 0." } { $examples - { $example "USE: math.statistics" "{ 1 } var ." "0" } - { $example "USE: math.statistics" "{ 1 2 3 } var ." "1" } - { $example "USE: math.statistics" "{ 1 2 3 4 } var ." "5/3" } } ; + { $example "USING: math.statistics prettyprint ;" "{ 1 } var ." "0" } + { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 } var ." "1" } + { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 4 } var ." "1+2/3" } } ; diff --git a/extra/math/text/english/english-docs.factor b/extra/math/text/english/english-docs.factor index d544f49ad8..a7fdc421aa 100644 --- a/extra/math/text/english/english-docs.factor +++ b/extra/math/text/english/english-docs.factor @@ -4,4 +4,4 @@ IN: math.text.english HELP: number>text { $values { "n" integer } { "str" string } } { $description "Converts an integer to a text string representation in English, including appropriate punctuation and conjunctions." } -{ $examples { $example "12345 number>text ." "\"Twelve Thousand, Three Hundred and Forty-Five\"" } } ; +{ $examples { $example "USING: math.text.english prettyprint ;" "12345 number>text ." "\"Twelve Thousand, Three Hundred and Forty-Five\"" } } ; diff --git a/extra/math/vectors/vectors-docs.factor b/extra/math/vectors/vectors-docs.factor index fe33dd65e3..140eddb2f6 100755 --- a/extra/math/vectors/vectors-docs.factor +++ b/extra/math/vectors/vectors-docs.factor @@ -69,12 +69,12 @@ HELP: v/ HELP: vmax { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "w" "a sequence of real numbers" } } { $description "Creates a sequence where each element is the maximum of the corresponding elements from " { $snippet "u" } " andd " { $snippet "v" } "." } -{ $examples { $example "USE: math.vectors" "{ 1 2 5 } { -7 6 3 } vmax ." "{ 1 6 5 }" } } ; +{ $examples { $example "USING: math.vectors prettyprint ;" "{ 1 2 5 } { -7 6 3 } vmax ." "{ 1 6 5 }" } } ; HELP: vmin { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "w" "a sequence of real numbers" } } { $description "Creates a sequence where each element is the minimum of the corresponding elements from " { $snippet "u" } " andd " { $snippet "v" } "." } -{ $examples { $example "USE: math.vectors" "{ 1 2 5 } { -7 6 3 } vmin ." "{ -7 2 3 }" } } ; +{ $examples { $example "USING: math.vectors prettyprint ;" "{ 1 2 5 } { -7 6 3 } vmin ." "{ -7 2 3 }" } } ; HELP: v. { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "x" "a real number" } } @@ -99,7 +99,7 @@ HELP: normalize HELP: set-axis { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "axis" "a sequence of 0/1" } { "w" "a sequence of numbers" } } { $description "Using " { $snippet "w" } " as a template, creates a new sequence containing corresponding elements from " { $snippet "u" } " in place of 0, and corresponding elements from " { $snippet "v" } " in place of 1." } -{ $examples { $example "USE: math.vectors" "{ 1 2 3 } { 4 5 6 } { 0 1 0 } set-axis ." "{ 1 5 3 }" } } ; +{ $examples { $example "USING: math.vectors prettyprint ;" "{ 1 2 3 } { 4 5 6 } { 0 1 0 } set-axis ." "{ 1 5 3 }" } } ; { 2map v+ v- v* v/ } related-words diff --git a/extra/opengl/capabilities/capabilities-docs.factor b/extra/opengl/capabilities/capabilities-docs.factor index e73b7a3f0b..f5424e19da 100644 --- a/extra/opengl/capabilities/capabilities-docs.factor +++ b/extra/opengl/capabilities/capabilities-docs.factor @@ -43,7 +43,7 @@ HELP: has-gl-extensions? { $description "Returns true if the set of " { $snippet "extensions" } " is a subset of the implementation-supported extensions returned by " { $link gl-extensions } "." } ; HELP: has-gl-version-or-extensions? -{ $values { "version" "A version string" } { "extensions" "A sequence of extension name strings" } } +{ $values { "version" "A version string" } { "extensions" "A sequence of extension name strings" } { "?" "a boolean" } } { $description "Returns true if either " { $link has-gl-version? } " or " { $link has-gl-extensions? } " returns true for " { $snippet "version" } " or " { $snippet "extensions" } ", respectively. Intended for use when required OpenGL functionality can be verified either by a minimum version or a set of equivalent extensions." } ; HELP: require-gl-extensions diff --git a/extra/opengl/shaders/shaders-docs.factor b/extra/opengl/shaders/shaders-docs.factor index e065367323..93251627f4 100644 --- a/extra/opengl/shaders/shaders-docs.factor +++ b/extra/opengl/shaders/shaders-docs.factor @@ -1,5 +1,5 @@ USING: help.markup help.syntax io kernel math quotations -opengl.gl multiline assocs ; +opengl.gl multiline assocs strings ; IN: opengl.shaders HELP: gl-shader @@ -28,19 +28,19 @@ HELP: fragment-shader } ; HELP: -{ $values { "source" "The GLSL source code to compile" } { "kind" "The kind of shader to compile, such as " { $snippet "GL_VERTEX_SHADER" } " or " { $snippet "GL_FRAGMENT_SHADER" } } } +{ $values { "source" "The GLSL source code to compile" } { "kind" "The kind of shader to compile, such as " { $snippet "GL_VERTEX_SHADER" } " or " { $snippet "GL_FRAGMENT_SHADER" } } { "shader" "a new " { $link gl-shader } } } { $description "Tries to compile the given GLSL source into a shader object. The returned object can be checked for validity by " { $link check-gl-shader } " or " { $link gl-shader-ok? } ". Errors and warnings generated by the GLSL compiler will be collected in the info log, available from " { $link gl-shader-info-log } ".\n\nWhen the shader object is no longer needed, it should be deleted using " { $link delete-gl-shader } " or else be attached to a " { $link gl-program } " object deleted using " { $link delete-gl-program } "." } ; HELP: -{ $values { "source" "The GLSL source code to compile" } } +{ $values { "source" "The GLSL source code to compile" } { "vertex-shader" "a new " { $link vertex-shader } } } { $description "Tries to compile the given GLSL source into a vertex shader object. Equivalent to " { $snippet "GL_VERTEX_SHADER " } "." } ; HELP: -{ $values { "source" "The GLSL source code to compile" } } +{ $values { "source" "The GLSL source code to compile" } { "fragment-shader" "a new " { $link fragment-shader } } } { $description "Tries to compile the given GLSL source into a fragment shader object. Equivalent to " { $snippet "GL_FRAGMENT_SHADER " } "." } ; HELP: gl-shader-ok? -{ $values { "shader" "A " { $link gl-shader } " object" } } +{ $values { "shader" "A " { $link gl-shader } " object" } { "?" "a boolean" } } { $description "Returns a boolean value indicating whether the given shader object compiled successfully. Compilation errors and warnings are available in the shader's info log, which can be gotten using " { $link gl-shader-info-log } "." } ; HELP: check-gl-shader @@ -52,7 +52,7 @@ HELP: delete-gl-shader { $description "Deletes the shader object, invalidating it and releasing any resources allocated for it by the OpenGL implementation." } ; HELP: gl-shader-info-log -{ $values { "shader" "A " { $link gl-shader } " object" } } +{ $values { "shader" "A " { $link gl-shader } " object" } { "shader" "a new " { $link gl-shader } } { "log" string } } { $description "Retrieves the info log for " { $snippet "shader" } ", including any errors or warnings generated in compiling the shader object." } ; HELP: gl-program @@ -69,17 +69,17 @@ HELP: gl-program } ; HELP: -{ $values { "shaders" "A sequence of " { $link gl-shader } " objects." } } +{ $values { "shaders" "A sequence of " { $link gl-shader } " objects." } { "program" "a new " { $link gl-program } } } { $description "Creates a new GLSL program object, attaches all the shader objects in the " { $snippet "shaders" } " sequence, and attempts to link them. The returned object can be checked for validity by " { $link check-gl-program } " or " { $link gl-program-ok? } ". Errors and warnings generated by the GLSL linker will be collected in the info log, available from " { $link gl-program-info-log } ".\n\nWhen the program object and its attached shaders are no longer needed, it should be deleted using " { $link delete-gl-program } "." } ; HELP: -{ $values { "vertex-shader-source" "A string containing GLSL vertex shader source" } { "fragment-shader-source" "A string containing GLSL fragment shader source" } } +{ $values { "vertex-shader-source" "A string containing GLSL vertex shader source" } { "fragment-shader-source" "A string containing GLSL fragment shader source" } { "program" "a new " { $link gl-program } } } { $description "Wrapper for " { $link } " for the simple case of compiling a single vertex shader and fragment shader and linking them into a GLSL program. Throws an exception if compiling or linking fails." } ; { } related-words HELP: gl-program-ok? -{ $values { "program" "A " { $link gl-program } " object" } } +{ $values { "program" "A " { $link gl-program } " object" } { "?" "a boolean" } } { $description "Returns a boolean value indicating whether the given program object linked successfully. Link errors and warnings are available in the program's info log, which can be gotten using " { $link gl-program-info-log } "." } ; HELP: check-gl-program @@ -87,7 +87,7 @@ HELP: check-gl-program { $description "Throws an error containing the " { $link gl-program-info-log } " for the program object if it failed to link. Otherwise, the program object is left on the stack." } ; HELP: gl-program-info-log -{ $values { "program" "A " { $link gl-program } " object" } } +{ $values { "program" "A " { $link gl-program } " object" } { "log" string } } { $description "Retrieves the info log for " { $snippet "program" } ", including any errors or warnings generated in linking the program object." } ; HELP: delete-gl-program diff --git a/extra/opengl/shaders/shaders.factor b/extra/opengl/shaders/shaders.factor index 0ff708d6d4..fbbc4c496a 100644 --- a/extra/opengl/shaders/shaders.factor +++ b/extra/opengl/shaders/shaders.factor @@ -50,7 +50,7 @@ IN: opengl.shaders alien>char-string ] with-malloc ; -: check-gl-shader ( shader -- shader* ) +: check-gl-shader ( shader -- shader ) dup gl-shader-ok? [ dup gl-shader-info-log throw ] unless ; : delete-gl-shader ( shader -- ) glDeleteShader ; inline @@ -85,7 +85,7 @@ PREDICATE: gl-shader fragment-shader (fragment-shader?) ; alien>char-string ] with-malloc ; -: check-gl-program ( program -- program* ) +: check-gl-program ( program -- program ) dup gl-program-ok? [ dup gl-program-info-log throw ] unless ; : gl-program-shaders-length ( program -- shaders-length ) diff --git a/extra/parser-combinators/parser-combinators-docs.factor b/extra/parser-combinators/parser-combinators-docs.factor index 774069d5a5..41171ce822 100755 --- a/extra/parser-combinators/parser-combinators-docs.factor +++ b/extra/parser-combinators/parser-combinators-docs.factor @@ -12,7 +12,7 @@ HELP: list-of "'items' is a parser that can parse the individual elements. 'separator' " "is a parser for the symbol that separatest them. The result tree of " "the resulting parser is an array of the parsed elements." } -{ $example "USE: parser-combinators" "\"1,2,3,4\" 'integer' \",\" token list-of parse-1 ." "{ 1 2 3 4 }" } +{ $example "USING: parser-combinators parser-combinators.simple prettyprint ;" "\"1,2,3,4\" 'integer' \",\" token list-of parse-1 ." "{ 1 2 3 4 }" } { $see-also list-of } ; HELP: any-char-parser @@ -23,4 +23,4 @@ HELP: any-char-parser "from the input string. The value consumed is the " "result of the parse." } { $examples -{ $example "USING: lazy-lists parser-combinators ;" "\"foo\" any-char-parser parse-1 ." "102" } } ; +{ $example "USING: lazy-lists parser-combinators prettyprint ;" "\"foo\" any-char-parser parse-1 ." "102" } } ; diff --git a/extra/parser-combinators/simple/simple-docs.factor b/extra/parser-combinators/simple/simple-docs.factor index bba37ca4ca..78b731f5b0 100755 --- a/extra/parser-combinators/simple/simple-docs.factor +++ b/extra/parser-combinators/simple/simple-docs.factor @@ -11,7 +11,7 @@ HELP: 'digit' "the input string. The numeric value of the digit " " consumed is the result of the parse." } { $examples -{ $example "USING: lazy-lists parser-combinators ;" "\"123\" 'digit' parse-1 ." "1" } } ; +{ $example "USING: lazy-lists parser-combinators parser-combinators.simple prettyprint ;" "\"123\" 'digit' parse-1 ." "1" } } ; HELP: 'integer' { $values @@ -21,7 +21,7 @@ HELP: 'integer' "the input string. The numeric value of the integer " " consumed is the result of the parse." } { $examples -{ $example "USING: lazy-lists parser-combinators ;" "\"123\" 'integer' parse-1 ." "123" } } ; +{ $example "USING: lazy-lists parser-combinators parser-combinators.simple prettyprint ;" "\"123\" 'integer' parse-1 ." "123" } } ; HELP: 'string' { $values { "parser" "a parser object" } } @@ -30,7 +30,8 @@ HELP: 'string' "quotations from the input string. The string value " " consumed is the result of the parse." } { $examples -{ $example "USING: lazy-lists parser-combinators ;" "\"\\\"foo\\\"\" 'string' parse-1 ." "\"foo\"" } } ; +{ $example "USING: lazy-lists parser-combinators parser-combinators.simple prettyprint ;" "\"\\\"foo\\\"\" 'string' parse-1 ." "\"foo\"" } } ; + HELP: 'bold' { $values { "parser" "a parser object" } } @@ -39,8 +40,9 @@ HELP: 'bold' "the '*' character from the input string. This is " "commonly used in markup languages to indicate bold " "faced text." } -{ $example "USE: parser-combinators" "\"*foo*\" 'bold' parse-1 ." "\"foo\"" } -{ $example "USE: parser-combinators" "\"*foo*\" 'bold' [ \"\" swap \"\" 3append ] <@ parse-1 ." "\"foo\"" } ; +{ $example "USING: parser-combinators parser-combinators.simple prettyprint ;" "\"*foo*\" 'bold' parse-1 ." "\"foo\"" } +{ $example "USING: kernel parser-combinators parser-combinators.simple prettyprint sequences ;" "\"*foo*\" 'bold' [ \"\" swap \"\" 3append ] <@ parse-1 ." "\"foo\"" } ; + HELP: 'italic' { $values { "parser" "a parser object" } } @@ -50,8 +52,8 @@ HELP: 'italic' "commonly used in markup languages to indicate italic " "faced text." } { $examples -{ $example "USING: lazy-lists parser-combinators ;" "\"_foo_\" 'italic' parse-1 ." "\"foo\"" } -{ $example "USING: lazy-lists parser-combinators ;" "\"_foo_\" 'italic' [ \"\" swap \"\" 3append ] <@ parse-1 ." "\"foo\"" } } ; +{ $example "USING: parser-combinators parser-combinators.simple prettyprint ;" "\"_foo_\" 'italic' parse-1 ." "\"foo\"" } +{ $example "USING: kernel parser-combinators parser-combinators.simple prettyprint sequences ;" "\"_foo_\" 'italic' [ \"\" swap \"\" 3append ] <@ parse-1 ." "\"foo\"" } } ; HELP: comma-list { $values { "element" "a parser object" } { "parser" "a parser object" } } @@ -60,6 +62,6 @@ HELP: comma-list "'element' should be a parser that can parse the elements. The " "result of the parser is a sequence of the parsed elements." } { $examples -{ $example "USING: lazy-lists parser-combinators ;" "\"1,2,3,4\" 'integer' comma-list parse-1 ." "{ 1 2 3 4 }" } } ; +{ $example "USING: lazy-lists parser-combinators parser-combinators.simple prettyprint ;" "\"1,2,3,4\" 'integer' comma-list parse-1 ." "{ 1 2 3 4 }" } } ; { $see-also 'digit' 'integer' 'string' 'bold' 'italic' comma-list } related-words diff --git a/extra/peg/parsers/parsers-docs.factor b/extra/peg/parsers/parsers-docs.factor index 437edc1007..91b084f89d 100755 --- a/extra/peg/parsers/parsers-docs.factor +++ b/extra/peg/parsers/parsers-docs.factor @@ -18,24 +18,26 @@ HELP: list-of { $values { "items" "a sequence" } { "separator" "a parser" } + { "parser" "a parser" } } { $description "Returns a parser that returns a list of items separated by the separator parser. Hides the separators and matches a list of one or more items." } { $notes "Use " { $link list-of-many } " to ensure a list contains two or more items." } { $examples - { $example "\"a\" \"a\" token \",\" token list-of parse parse-result-ast ." "V{ \"a\" }" } - { $example "\"a,a,a,a\" \"a\" token \",\" token list-of parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } + { $example "USING: peg peg.parsers prettyprint ;" "\"a\" \"a\" token \",\" token list-of parse parse-result-ast ." "V{ \"a\" }" } + { $example "USING: peg peg.parsers prettyprint ;" "\"a,a,a,a\" \"a\" token \",\" token list-of parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } } { $see-also list-of-many } ; HELP: list-of-many { $values { "items" "a sequence" } { "separator" "a parser" } + { "parser" "a parser" } } { $description "Returns a parser that returns a list of items separated by the separator parser. Hides the separators and matches a list of two or more items." } { $notes "Use " { $link list-of } " to return a list of only one item." } { $examples - { $example "\"a\" \"a\" token \",\" token list-of-many parse ." "f" } - { $example "\"a,a,a,a\" \"a\" token \",\" token list-of-many parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } + { $example "USING: peg peg.parsers prettyprint ;" "\"a\" \"a\" token \",\" token list-of-many parse ." "f" } + { $example "USING: peg peg.parsers prettyprint ;" "\"a,a,a,a\" \"a\" token \",\" token list-of-many parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } } { $see-also list-of } ; HELP: epsilon @@ -60,8 +62,8 @@ HELP: exactly-n } { $description "Returns a parser that matches an exact repetition of the input parser." } { $examples - { $example "\"aaa\" \"a\" token 4 exactly-n parse ." "f" } - { $example "\"aaaa\" \"a\" token 4 exactly-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } + { $example "USING: peg peg.parsers prettyprint ;" "\"aaa\" \"a\" token 4 exactly-n parse ." "f" } + { $example "USING: peg peg.parsers prettyprint ;" "\"aaaa\" \"a\" token 4 exactly-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } } { $see-also at-least-n at-most-n from-m-to-n } ; HELP: at-least-n @@ -72,9 +74,9 @@ HELP: at-least-n } { $description "Returns a parser that matches n or more repetitions of the input parser." } { $examples - { $example "\"aaa\" \"a\" token 4 at-least-n parse ." "f" } - { $example "\"aaaa\" \"a\" token 4 at-least-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } - { $example "\"aaaaa\" \"a\" token 4 at-least-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" \"a\" }" } + { $example "USING: peg peg.parsers prettyprint ;" "\"aaa\" \"a\" token 4 at-least-n parse ." "f" } + { $example "USING: peg peg.parsers prettyprint ;" "\"aaaa\" \"a\" token 4 at-least-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } + { $example "USING: peg peg.parsers prettyprint ;" "\"aaaaa\" \"a\" token 4 at-least-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" \"a\" }" } } { $see-also exactly-n at-most-n from-m-to-n } ; HELP: at-most-n @@ -85,8 +87,8 @@ HELP: at-most-n } { $description "Returns a parser that matches n or fewer repetitions of the input parser." } { $examples - { $example "\"aaaa\" \"a\" token 4 at-most-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } - { $example "\"aaaaa\" \"a\" token 4 at-most-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } + { $example "USING: peg peg.parsers prettyprint ;" "\"aaaa\" \"a\" token 4 at-most-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } + { $example "USING: peg peg.parsers prettyprint ;" "\"aaaaa\" \"a\" token 4 at-most-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } } { $see-also exactly-n at-least-n from-m-to-n } ; HELP: from-m-to-n @@ -98,9 +100,9 @@ HELP: from-m-to-n } { $description "Returns a parser that matches between and including m to n repetitions of the input parser." } { $examples - { $example "\"aaa\" \"a\" token 3 4 from-m-to-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" }" } - { $example "\"aaaa\" \"a\" token 3 4 from-m-to-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } - { $example "\"aaaaa\" \"a\" token 3 4 from-m-to-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } + { $example "USING: peg peg.parsers prettyprint ;" "\"aaa\" \"a\" token 3 4 from-m-to-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" }" } + { $example "USING: peg peg.parsers prettyprint ;" "\"aaaa\" \"a\" token 3 4 from-m-to-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } + { $example "USING: peg peg.parsers prettyprint ;" "\"aaaaa\" \"a\" token 3 4 from-m-to-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } } { $see-also exactly-n at-most-n at-least-n } ; HELP: pack @@ -108,11 +110,11 @@ HELP: pack { "begin" "a parser" } { "body" "a parser" } { "end" "a parser" } - { "parser'" "a parser" } + { "parser" "a parser" } } { $description "Returns a parser that parses the begin, body, and end parsers in order. The begin and end parsers are hidden." } { $examples - { $example "\"hi123bye\" \"hi\" token 'integer' \"bye\" token pack parse parse-result-ast ." "123" } + { $example "USING: peg peg.parsers prettyprint ;" "\"hi123bye\" \"hi\" token 'integer' \"bye\" token pack parse parse-result-ast ." "123" } } { $see-also surrounded-by } ; HELP: surrounded-by @@ -124,7 +126,7 @@ HELP: surrounded-by } { $description "Calls token on begin and end to make them into string parsers. Returns a parser that parses the begin, body, and end parsers in order. The begin and end parsers are hidden." } { $examples - { $example "\"hi123bye\" 'integer' \"hi\" \"bye\" surrounded-by parse parse-result-ast ." "123" } + { $example "USING: peg peg.parsers prettyprint ;" "\"hi123bye\" 'integer' \"hi\" \"bye\" surrounded-by parse parse-result-ast ." "123" } } { $see-also pack } ; HELP: 'digit' diff --git a/extra/peg/search/search-docs.factor b/extra/peg/search/search-docs.factor index fc1e618b9b..565601ea11 100755 --- a/extra/peg/search/search-docs.factor +++ b/extra/peg/search/search-docs.factor @@ -10,7 +10,7 @@ HELP: tree-write "Write the object to the standard output stream, unless " "it is an array, in which case recurse through the array " "writing each object to the stream." } -{ $example "{ 65 \"bc\" { 68 \"ef\" } } tree-write" "AbcDef" } ; +{ $example "USE: peg.search" "{ 65 \"bc\" { 68 \"ef\" } } tree-write" "AbcDef" } ; HELP: search { $values @@ -24,8 +24,8 @@ HELP: search "parser." } -{ $example "\"one 123 two 456\" 'integer' search" "V{ 123 456 }" } -{ $example "\"one 123 \\\"hello\\\" two 456\" 'integer' 'string' 2array choice search" "V{ 123 \"hello\" 456 }" } +{ $example "USING: peg.parsers peg.search prettyprint ;" "\"one 123 two 456\" 'integer' search ." "V{ 123 456 }" } +{ $example "USING: peg peg.parsers peg.search prettyprint ;" "\"one 123 \\\"hello\\\" two 456\" 'integer' 'string' 2choice search ." "V{ 123 \"hello\" 456 }" } { $see-also replace } ; HELP: replace @@ -39,6 +39,6 @@ HELP: replace "successfully parse with the given parser replaced with " "the result of that parser." } -{ $example "\"one 123 two 456\" 'integer' [ 2 * number>string ] action replace" "\"one 246 two 912\"" } +{ $example "USING: math math.parser peg peg.parsers peg.search prettyprint ;" "\"one 123 two 456\" 'integer' [ 2 * number>string ] action replace ." "\"one 246 two 912\"" } { $see-also search } ; diff --git a/extra/promises/promises-docs.factor b/extra/promises/promises-docs.factor index 1adc14ca77..ade3357f34 100755 --- a/extra/promises/promises-docs.factor +++ b/extra/promises/promises-docs.factor @@ -29,6 +29,6 @@ HELP: LAZY: { $values { "word" "a new word to define" } { "definition" "a word definition" } } { $description "Creates a lazy word in the current vocabulary. When executed the word will return a " { $link promise } " that when forced, executes the word definition. Any values on the stack that are required by the word definition are captured along with the promise." } { $examples - { $example "IN: promises LAZY: my-add ( a b -- c ) + ;\n1 2 my-add force ." "3" } + { $example "USING: math prettyprint promises ;" "LAZY: my-add ( a b -- c ) + ;" "1 2 my-add force ." "3" } } { $see-also force promise-with promise-with2 } ; diff --git a/extra/sequences/lib/lib-docs.factor b/extra/sequences/lib/lib-docs.factor index eb56e35cd5..6f4a173874 100755 --- a/extra/sequences/lib/lib-docs.factor +++ b/extra/sequences/lib/lib-docs.factor @@ -8,7 +8,7 @@ HELP: map-withn "passed to the quotation given to map-withn for each element in the sequence." } { $examples - { $example "USE: combinators.lib" "1 2 3 4 { 6 7 8 9 10 } [ + + + + ] 4 map-withn .s" "{ 16 17 18 19 20 }" } + { $example "USING: math sequences.lib prettyprint ;" "1 2 3 4 { 6 7 8 9 10 } [ + + + + ] 4 map-withn .s" "{ 16 17 18 19 20 }" } } { $see-also each-withn } ; @@ -24,7 +24,7 @@ HELP: sigma { $description "Like map sum, but without creating an intermediate sequence." } { $example "! Find the sum of the squares [0,99]" - "USING: math.ranges combinators.lib ;" + "USING: math math.ranges sequences.lib prettyprint ;" "100 [1,b] [ sq ] sigma ." "338350" } ; @@ -33,7 +33,7 @@ HELP: count { $values { "seq" sequence } { "quot" quotation } { "n" integer } } { $description "Efficiently returns the number of elements that the predicate quotation matches." } { $example - "USING: math.ranges combinators.lib ;" + "USING: math math.ranges sequences.lib prettyprint ;" "100 [1,b] [ even? ] count ." "50" } ; diff --git a/extra/serialize/serialize-docs.factor b/extra/serialize/serialize-docs.factor index 6b2dd304f5..fc060d6b33 100755 --- a/extra/serialize/serialize-docs.factor +++ b/extra/serialize/serialize-docs.factor @@ -8,7 +8,7 @@ HELP: serialize } { $description "Serializes the object to the current output stream. Object references within the structure being serialized are maintained." } { $examples - { $example "USING: serialize io.streams.string ;" "binary [ { 1 2 } serialize ] with-byte-writer\n\nbinary [ deserialize ] with-byte-reader ." "{ 1 2 }" } + { $example "USING: serialize io.encodings.binary io.streams.byte-array prettyprint ;" "binary [ { 1 2 } serialize ] with-byte-writer\n\nbinary [ deserialize ] with-byte-reader ." "{ 1 2 }" } } { $see-also deserialize } ; @@ -17,6 +17,6 @@ HELP: deserialize } { $description "Deserializes an object by reading from the current input stream. Object references within the structure that was originally serialized are maintained." } { $examples - { $example "USING: serialize io.streams.string ;" "binary [ { 1 2 } serialize ] with-byte-writer\n\nbinary [ deserialize ] with-byte-reader ." "{ 1 2 }" } + { $example "USING: serialize io.encodings.binary io.streams.byte-array prettyprint ;" "binary [ { 1 2 } serialize ] with-byte-writer\n\nbinary [ deserialize ] with-byte-reader ." "{ 1 2 }" } } { $see-also serialize } ; diff --git a/extra/shuffle/shuffle-docs.factor b/extra/shuffle/shuffle-docs.factor index 8f6ccc410a..4caace3b00 100755 --- a/extra/shuffle/shuffle-docs.factor +++ b/extra/shuffle/shuffle-docs.factor @@ -11,7 +11,7 @@ HELP: npick "placed on the top of the stack." } { $examples - { $example "USE: shuffle" "1 2 3 4 4 npick .s" "1\n2\n3\n4\n1" } + { $example "USING: prettyprint shuffle ;" "1 2 3 4 4 npick .s" "1\n2\n3\n4\n1" } } { $see-also dup over pick } ; @@ -23,7 +23,7 @@ HELP: ndup "placed on the top of the stack." } { $examples - { $example "USE: shuffle" "1 2 3 4 4 ndup .s" "1\n2\n3\n4\n1\n2\n3\n4" } + { $example "USING: prettyprint shuffle ;" "1 2 3 4 4 ndup .s" "1\n2\n3\n4\n1\n2\n3\n4" } } { $see-also dup 2dup 3dup } ; @@ -34,7 +34,7 @@ HELP: nnip "for any number of items." } { $examples - { $example "USE: shuffle" "1 2 3 4 3 nnip .s" "4" } + { $example "USING: prettyprint shuffle ;" "1 2 3 4 3 nnip .s" "4" } } { $see-also nip 2nip } ; @@ -45,7 +45,7 @@ HELP: ndrop "for any number of items." } { $examples - { $example "USE: shuffle" "1 2 3 4 3 ndrop .s" "1" } + { $example "USING: prettyprint shuffle ;" "1 2 3 4 3 ndrop .s" "1" } } { $see-also drop 2drop 3drop } ; @@ -55,7 +55,7 @@ HELP: nrot "number of items on the stack. " } { $examples - { $example "USE: shuffle" "1 2 3 4 4 nrot .s" "2\n3\n4\n1" } + { $example "USING: prettyprint shuffle ;" "1 2 3 4 4 nrot .s" "2\n3\n4\n1" } } { $see-also rot -nrot } ; @@ -65,7 +65,7 @@ HELP: -nrot "number of items on the stack. " } { $examples - { $example "USE: shuffle" "1 2 3 4 4 -nrot .s" "4\n1\n2\n3" } + { $example "USING: prettyprint shuffle ;" "1 2 3 4 4 -nrot .s" "4\n1\n2\n3" } } { $see-also rot nrot } ; diff --git a/extra/singleton/singleton-docs.factor b/extra/singleton/singleton-docs.factor index 358d1a5bf6..92ddcc494a 100644 --- a/extra/singleton/singleton-docs.factor +++ b/extra/singleton/singleton-docs.factor @@ -8,7 +8,7 @@ HELP: SINGLETON: } { $description "Defines a new predicate class whose superclass is " { $link word } ". Only one instance of a singleton may exist because classes are " { $link eq? } " to themselves. Methods may be defined on a singleton." } { $examples - { $example "SINGLETON: foo\nGENERIC: bar ( obj -- )\nM: foo bar drop \"a foo!\" print ;\nfoo bar" "a foo!" } + { $example "USING: singleton kernel io ;" "SINGLETON: foo\nGENERIC: bar ( obj -- )\nM: foo bar drop \"a foo!\" print ;\nfoo bar" "a foo!" } } { $see-also POSTPONE: PREDICATE: } ; @@ -20,7 +20,7 @@ HELP: SINGLETONS: } { $description "Defines a new singleton for each class in the list." } { $examples - { $example "SINGLETONS: foo bar baz ;" "" } + { $example "USE: singleton" "SINGLETONS: foo bar baz ;" "" } } { $see-also POSTPONE: SINGLETON: } ; diff --git a/extra/symbols/symbols-docs.factor b/extra/symbols/symbols-docs.factor index c6886ce31a..f542948970 100644 --- a/extra/symbols/symbols-docs.factor +++ b/extra/symbols/symbols-docs.factor @@ -5,5 +5,5 @@ HELP: SYMBOLS: { $syntax "SYMBOLS: words... ;" } { $values { "words" "a sequence of new words to define" } } { $description "Creates a new word for every token until the ';'." } -{ $examples { $example "SYMBOLS: foo bar baz ;\nfoo . bar . baz ." "foo\nbar\nbaz" } } +{ $examples { $example "USING: prettyprint symbols ;" "SYMBOLS: foo bar baz ;\nfoo . bar . baz ." "foo\nbar\nbaz" } } { $see-also POSTPONE: SYMBOL: } ; diff --git a/extra/tools/completion/completion-docs.factor b/extra/tools/completion/completion-docs.factor index 7683ef1ca1..4d7154fb2d 100644 --- a/extra/tools/completion/completion-docs.factor +++ b/extra/tools/completion/completion-docs.factor @@ -24,7 +24,7 @@ HELP: runs { $values { "seq" "a sequence of integers" } { "newseq" "a sequence of sequences of integers" } } { $description "Groups subsequences of consecutive integers." } { $examples - { $example "USE: tools.completion" "{ 1 2 3 5 6 9 10 } runs ." "V{ V{ 1 2 3 } V{ 5 6 } V{ 9 10 } }" } + { $example "USING: prettyprint tools.completion ;" "{ 1 2 3 5 6 9 10 } runs ." "V{ V{ 1 2 3 } V{ 5 6 } V{ 9 10 } }" } } ; HELP: score diff --git a/extra/tools/disassembler/disassembler.factor b/extra/tools/disassembler/disassembler.factor index 1e003dcf69..2fa882ff68 100755 --- a/extra/tools/disassembler/disassembler.factor +++ b/extra/tools/disassembler/disassembler.factor @@ -33,6 +33,6 @@ M: pair make-disassemble-cmd : tabs>spaces ( str -- str' ) { { CHAR: \t CHAR: \s } } substitute ; -: disassemble ( word -- ) +: disassemble ( obj -- ) make-disassemble-cmd run-gdb [ tabs>spaces ] map [ print ] each ; diff --git a/extra/tools/test/test-docs.factor b/extra/tools/test/test-docs.factor index 743822e7f9..a605543bda 100755 --- a/extra/tools/test/test-docs.factor +++ b/extra/tools/test/test-docs.factor @@ -89,6 +89,6 @@ HELP: run-all-tests { $values { "prefix" "a vocabulary name" } { "failures" "an association list of unit test failures" } } { $description "Runs unit tests for all loaded vocabularies and outputs unit test failures as documented in " { $link "tools.test.failure" } "." } ; -HELP: failure. -{ $values { "failures" "an association list of unit test failures" } } +HELP: test-failures. +{ $values { "assoc" "an association list of unit test failures" } } { $description "Prints unit test failures output by " { $link run-tests } " or " { $link run-all-tests } " to the " { $link stdio } " stream." } ; diff --git a/extra/trees/splay/splay-docs.factor b/extra/trees/splay/splay-docs.factor index 1c49febe01..253d3f4aec 100644 --- a/extra/trees/splay/splay-docs.factor +++ b/extra/trees/splay/splay-docs.factor @@ -11,7 +11,7 @@ HELP: { $description "Creates an empty splay tree" } ; HELP: >splay -{ $values { "assoc" assoc } { "splay" splay } } +{ $values { "assoc" assoc } { "tree" splay } } { $description "Converts any " { $link assoc } " into an splay tree." } ; HELP: splay diff --git a/extra/trees/splay/splay.factor b/extra/trees/splay/splay.factor index 2fca5eca95..7746db85d3 100644 --- a/extra/trees/splay/splay.factor +++ b/extra/trees/splay/splay.factor @@ -6,7 +6,7 @@ IN: trees.splay TUPLE: splay ; -: ( -- splay-tree ) +: ( -- tree ) \ splay construct-tree ; INSTANCE: splay tree-mixin @@ -130,7 +130,7 @@ M: splay delete-at ( key tree -- ) M: splay new-assoc 2drop ; -: >splay ( assoc -- splay-tree ) +: >splay ( assoc -- tree ) T{ splay T{ tree f f 0 } } assoc-clone-like ; : SPLAY{ diff --git a/extra/tuples/lib/lib-docs.factor b/extra/tuples/lib/lib-docs.factor index 0ab709a11f..75df1550f4 100644 --- a/extra/tuples/lib/lib-docs.factor +++ b/extra/tuples/lib/lib-docs.factor @@ -5,7 +5,7 @@ HELP: >tuple< { $values { "class" "a tuple class" } } { $description "Explodes the tuple so that tuple slots are on the stack in the order listed in the tuple." } { $example - "USE: tuples.lib" + "USING: kernel prettyprint tuples.lib ;" "TUPLE: foo a b c ;" "1 2 3 \\ foo construct-boa \\ foo >tuple< .s" "1\n2\n3" @@ -17,7 +17,7 @@ HELP: >tuple*< { $values { "class" "a tuple class" } } { $description "Explodes the tuple so that tuple slots ending with '*' are on the stack in the order listed in the tuple." } { $example - "USE: tuples.lib" + "USING: kernel prettyprint tuples.lib ;" "TUPLE: foo a bb* ccc dddd* ;" "1 2 3 4 \\ foo construct-boa \\ foo >tuple*< .s" "2\n4" diff --git a/extra/ui/commands/commands-docs.factor b/extra/ui/commands/commands-docs.factor index af2df94ade..789d9b9e6a 100644 --- a/extra/ui/commands/commands-docs.factor +++ b/extra/ui/commands/commands-docs.factor @@ -46,10 +46,10 @@ HELP: command-name { $description "Outputs a human-readable name for the command." } { $examples { $example - "USE: ui.commands" + "USING: io ui.commands ;" ": com-my-command ;" "\\ com-my-command command-name write" - "My command" + "My Command" } } ; @@ -104,10 +104,10 @@ HELP: command-string { $description "Outputs a string containing the command name followed by the gesture." } { $examples { $example - "USING: ui.commands ui.gestures ;" + "USING: io ui.commands ui.gestures ;" ": com-my-command ;" "T{ key-down f { C+ } \"s\" } \\ com-my-command command-string write" - "My command (C+s)" + "My Command (C+s)" } } ; diff --git a/extra/ui/gestures/gestures-docs.factor b/extra/ui/gestures/gestures-docs.factor index 95f2e5bf87..299498b1b8 100644 --- a/extra/ui/gestures/gestures-docs.factor +++ b/extra/ui/gestures/gestures-docs.factor @@ -194,7 +194,7 @@ HELP: gesture>string { $values { "gesture" "a gesture" } { "string/f" "a " { $link string } " or " { $link f } } } { $contract "Creates a human-readable string from a gesture object, returning " { $link f } " if the gesture does not have a human-readable form." } { $examples - { $example "USE: ui.gestures" "T{ key-down f { C+ } \"x\" } gesture>string print" "C+x" } + { $example "USING: io ui.gestures ;" "T{ key-down f { C+ } \"x\" } gesture>string print" "C+x" } } ; ARTICLE: "ui-gestures" "UI gestures" diff --git a/extra/xml/xml-docs.factor b/extra/xml/xml-docs.factor index a941e0de92..dd77d7c766 100644 --- a/extra/xml/xml-docs.factor +++ b/extra/xml/xml-docs.factor @@ -170,7 +170,7 @@ HELP: ( text -- instruction ) HELP: names-match? { $values { "name1" "a name" } { "name2" "a name" } { "?" "t or f" } } { $description "checks to see if the two names match, that is, if all fields are equal, ignoring fields whose value is f in either name." } -{ $example "USE: xml.data" "T{ name f \"rpc\" \"methodCall\" f } T{ name f f \"methodCall\" \"http://www.xmlrpc.org/\" } names-match? ." "t" } +{ $example "USING: prettyprint xml.data ;" "T{ name f \"rpc\" \"methodCall\" f } T{ name f f \"methodCall\" \"http://www.xmlrpc.org/\" } names-match? ." "t" } { $see-also name } ; HELP: xml-chunk diff --git a/misc/factor.sh b/misc/factor.sh index b86e486086..b96aa8d24b 100755 --- a/misc/factor.sh +++ b/misc/factor.sh @@ -56,7 +56,7 @@ check_ret() { check_gcc_version() { echo -n "Checking gcc version..." - GCC_VERSION=`gcc --version` + GCC_VERSION=`$CC --version` check_ret gcc if [[ $GCC_VERSION == *3.3.* ]] ; then echo "bad!" @@ -85,20 +85,35 @@ set_md5sum() { fi } +set_gcc() { + case $OS in + openbsd) ensure_program_installed egcc; CC=egcc;; + *) CC=gcc;; + esac +} + +set_make() { + case $OS in + netbsd) MAKE='gmake';; + freebsd) MAKE='gmake';; + openbsd) MAKE='gmake';; + dragonflybsd) MAKE='gmake';; + *) MAKE='make';; + esac + if ! [[ $MAKE -eq 'gmake' ]] ; then + ensure_program_installed gmake + fi +} + check_installed_programs() { ensure_program_installed chmod ensure_program_installed uname ensure_program_installed git ensure_program_installed wget curl ensure_program_installed gcc - ensure_program_installed make + ensure_program_installed make gmake ensure_program_installed md5sum md5 ensure_program_installed cut - case $OS in - netbsd) ensure_program_installed gmake;; - openbsd) ensure_program_installed gmake;; - freebsd) ensure_program_installed gmake;; - esac check_gcc_version } @@ -107,7 +122,7 @@ check_library_exists() { GCC_OUT=factor-library-test.out echo -n "Checking for library $1..." echo "int main(){return 0;}" > $GCC_TEST - gcc $GCC_TEST -o $GCC_OUT -l $1 + $CC $GCC_TEST -o $GCC_OUT -l $1 if [[ $? -ne 0 ]] ; then echo "not found!" echo "Warning: library $1 not found." @@ -157,6 +172,7 @@ find_os() { *NetBSD*) OS=netbsd;; *FreeBSD*) OS=freebsd;; *OpenBSD*) OS=openbsd;; + *DragonFly*) OS=dragonflybsd;; esac } @@ -208,6 +224,8 @@ echo_build_info() { echo GIT_PROTOCOL=$GIT_PROTOCOL echo GIT_URL=$GIT_URL echo DOWNLOADER=$DOWNLOADER + echo CC=$CC + echo MAKE=$MAKE } set_build_info() { @@ -241,6 +259,8 @@ find_build_info() { set_factor_binary set_build_info set_downloader + set_gcc + set_make echo_build_info } @@ -265,14 +285,8 @@ cd_factor() { } invoke_make() { - case $OS in - netbsd) make='gmake';; - freebsd) make='gmake';; - openbsd) make='gmake';; - *) make='make';; - esac - $make $* - check_ret $make + $MAKE $* + check_ret $MAKE } make_clean() {