Merge branch 'master' of git://github.com/slavapestov/factor
commit
2005df3b0c
|
@ -27,7 +27,7 @@ HELP: HEXCOLOR:
|
|||
|
||||
ARTICLE: "colors.hex" "HEX colors"
|
||||
"The " { $vocab-link "colors.hex" } " vocabulary implements colors specified "
|
||||
"by their hexidecimal value."
|
||||
"by their hexadecimal value."
|
||||
{ $subsections
|
||||
hex>rgba
|
||||
rgba>hex
|
||||
|
|
|
@ -4,7 +4,7 @@ IN: concurrency.distributed
|
|||
ARTICLE: "concurrency.distributed.example" "Distributed Concurrency Example"
|
||||
"In this example the Factor instance associated with port 9000 will run "
|
||||
"a thread that receives and prints messages "
|
||||
"in the listener. The code to start the thread is: "
|
||||
"in the listener. The code to start the thread is:"
|
||||
{ $examples
|
||||
{ $unchecked-example
|
||||
": log-message ( -- ) receive . flush log-message ;"
|
||||
|
|
|
@ -8,7 +8,7 @@ HELP: articles
|
|||
HELP: no-article
|
||||
{ $values { "name" "an article name" } }
|
||||
{ $description "Throws a " { $link no-article } " error." }
|
||||
{ $error-description "Thrown by " { $link help } " if the given help topic does not exist, or if the help topic being dispayed links to a help topic which does not exist." } ;
|
||||
{ $error-description "Thrown by " { $link help } " if the given help topic does not exist, or if the help topic being displayed links to a help topic which does not exist." } ;
|
||||
|
||||
HELP: article
|
||||
{ $values { "name" "an article name" } { "article" "an " { $link article } " object" } }
|
||||
|
|
|
@ -17,7 +17,7 @@ $nl
|
|||
{ { $slot "header" } { "An assoc of HTTP header values. See " { $link "http.headers" } } }
|
||||
{ { $slot "post-data" } { "See " { $link "http.post-data" } } }
|
||||
{ { $slot "cookies" } { "A sequence of HTTP cookies. See " { $link "http.cookies" } } }
|
||||
{ { $slot "redirects" } { "Number of redirects to attempt before throwing an error. Default is " { $snippet "max-redirects" } " ." } }
|
||||
{ { $slot "redirects" } { "Number of redirects to attempt before throwing an error. Default is " { $snippet "max-redirects" } "." } }
|
||||
} } ;
|
||||
|
||||
HELP: <response>
|
||||
|
|
|
@ -110,7 +110,7 @@ HELP: local
|
|||
HELP: inet
|
||||
{ $class-description "Host name/port number specifier for TCP/IP and UDP/IP connections. The " { $snippet "host" } " and " { $snippet "port" } " slots hold the host name and port name or number, respectively. New instances are created by calling " { $link <inet> } "." }
|
||||
{ $notes
|
||||
"This address specifier is only supported by " { $link <client> } ", which calls " { $link resolve-host } " to obtain a list of IP addresses associated with the host name, and attempts a connection to each one in turn until one succeeds. Other network words do not accept this address specifier, and " { $link resolve-host } " must be called directly; it is then up to the application to pick the correct address from the (possibly several) addresses associated to the host name."
|
||||
"This address specifier is only supported by " { $link <client> } ", which calls " { $link resolve-host } " to obtain a list of IP addresses associated with the host name, and attempts a connection to each one in turn until one succeeds. Other network words do not accept this address specifier, and " { $link resolve-host } " must be called directly; it is then up to the application to pick the correct address from the (possibly several) addresses associated to the host name."
|
||||
}
|
||||
{ $examples
|
||||
{ $code "\"www.apple.com\" 80 <inet>" }
|
||||
|
@ -143,7 +143,7 @@ HELP: <inet6>
|
|||
{ $description "Creates a new " { $link inet6 } " address specifier. A value of " { $link f } " as the host refers to localhost, while " { $link f } " as the port defers the port choice until a later time." } ;
|
||||
|
||||
HELP: <client>
|
||||
{ $values { "remote" "an address specifier" } { "encoding" "an encding descriptor" } { "stream" "a bidirectional stream" } { "local" "an address specifier" } }
|
||||
{ $values { "remote" "an address specifier" } { "encoding" "an encoding descriptor" } { "stream" "a bidirectional stream" } { "local" "an address specifier" } }
|
||||
{ $description "Opens a network connection and outputs a bidirectional stream using the given encoding, together with the local address the socket was bound to." }
|
||||
{ $errors "Throws an error if the connection cannot be established." }
|
||||
{ $notes "The " { $link with-client } " word is easier to use in most situations." }
|
||||
|
@ -157,7 +157,7 @@ HELP: with-client
|
|||
{ $errors "Throws an error if the connection cannot be established." } ;
|
||||
|
||||
HELP: <server>
|
||||
{ $values { "addrspec" "an address specifier" } { "encoding" "an encoding descriptor" } { "server" "a handle" } }
|
||||
{ $values { "addrspec" "an address specifier" } { "encoding" "an encoding descriptor" } { "server" "a handle" } }
|
||||
{ $description
|
||||
"Begins listening for network connections to a local address. Server objects respond to two words:"
|
||||
{ $list
|
||||
|
@ -225,7 +225,7 @@ HELP: with-local-address
|
|||
{ $description "Client sockets opened within the scope of the quotation passed to this combinator will have their local address bound to the given address." }
|
||||
{ $examples
|
||||
{ "Binds the local address of a newly created client socket within the quotation to 127.0.0.1."
|
||||
"This ensures that all traffic originates from the given address (the port is choosen by the TCP stack)." }
|
||||
"This ensures that all traffic originates from the given address (the port is chosen by the TCP stack)." }
|
||||
{ $code "\"127.0.0.1\" 0 <inet4> [ ] with-local-address" }
|
||||
$nl
|
||||
{ "Binds the local address of a newly created client socket within the quotation to the local address 192.168.0.1 and the local port 23000. "
|
||||
|
|
|
@ -16,9 +16,9 @@ HELP: MACRO:
|
|||
{ $examples
|
||||
"A macro that calls a quotation but preserves any values it consumes off the stack:"
|
||||
{ $code
|
||||
"USING: fry generalizations ;"
|
||||
"USING: fry generalizations kernel macros stack-checker ;"
|
||||
"MACRO: preserving ( quot -- )"
|
||||
" [ infer in>> length ] keep '[ _ ndup @ ] ;"
|
||||
" [ inputs ] keep '[ _ ndup @ ] ;"
|
||||
}
|
||||
"Using this macro, we can define a variant of " { $link if } " which takes a predicate quotation instead of a boolean; any values consumed by the predicate quotation are restored immediately after:"
|
||||
{ $code
|
||||
|
|
|
@ -150,7 +150,7 @@ int-4{ f f t f } ."""
|
|||
$nl
|
||||
"Providing a SIMD boolean vector with element values other than the proper true and false representations as an input to the vector logical or test operations is undefined. Do not count on operations such as " { $link vall? } " or " { $link v? } " using bitwise operations to construct their results."
|
||||
$nl
|
||||
"This applies to the output of the following element comparison words: "
|
||||
"This applies to the output of the following element comparison words:"
|
||||
{ $list
|
||||
{ $link v< }
|
||||
{ $link v<= }
|
||||
|
|
|
@ -319,7 +319,7 @@ ARTICLE: "peg.ebnf.tokenizers" "Tokenizers"
|
|||
"This parser when run with the string \"++--\" or the array "
|
||||
"{ CHAR: + CHAR: + CHAR: - CHAR: - } will succeed with an AST of { \"++\" \"--\" }. "
|
||||
"If you want to add whitespace handling to the grammar you need to put it "
|
||||
"between the terminals: "
|
||||
"between the terminals:"
|
||||
{ $examples
|
||||
{ $code
|
||||
"EBNF: foo"
|
||||
|
@ -332,7 +332,7 @@ ARTICLE: "peg.ebnf.tokenizers" "Tokenizers"
|
|||
"In a large grammar this gets tedious and makes the grammar hard to read. "
|
||||
"Instead you can write a rule to split the input sequence into tokens, and "
|
||||
"have the grammar operate on these tokens. This is how the previous example "
|
||||
"might look: "
|
||||
"might look:"
|
||||
{ $examples
|
||||
{ $code
|
||||
"EBNF: foo"
|
||||
|
@ -355,7 +355,7 @@ ARTICLE: "peg.ebnf.tokenizers" "Tokenizers"
|
|||
$nl
|
||||
"In this example I split the tokenizer into a separate parser and use "
|
||||
"'foreign' to call it from the main one. This allows testing of the "
|
||||
"tokenizer separately: "
|
||||
"tokenizer separately:"
|
||||
{ $examples
|
||||
{ $example
|
||||
"USING: prettyprint peg peg.ebnf kernel math.parser strings"
|
||||
|
@ -397,7 +397,7 @@ $nl
|
|||
"working in one pass. There is no tokenization occurring over the whole string "
|
||||
"followed by the parse of that result. It tokenizes as it needs to. You can even "
|
||||
"switch tokenizers multiple times during a grammar. Rules use the tokenizer that "
|
||||
"was defined lexically before the rule. This is usefull in the JavaScript grammar: "
|
||||
"was defined lexically before the rule. This is usefull in the JavaScript grammar:"
|
||||
{ $examples
|
||||
{ $code
|
||||
"EBNF: javascript"
|
||||
|
@ -440,7 +440,7 @@ ARTICLE: "peg.ebnf" "EBNF"
|
|||
POSTPONE: [EBNF
|
||||
POSTPONE: EBNF:
|
||||
}
|
||||
"The EBNF syntax is composed of a series of rules of the form: "
|
||||
"The EBNF syntax is composed of a series of rules of the form:"
|
||||
{ $code
|
||||
"rule1 = ..."
|
||||
"rule2 = ..."
|
||||
|
@ -448,7 +448,7 @@ ARTICLE: "peg.ebnf" "EBNF"
|
|||
"The last defined rule is the main rule for the EBNF. It is the first one run "
|
||||
"and it is expected that the remaining rules are used by that rule. Rules may be "
|
||||
"left recursive. "
|
||||
"Each rule can contain the following: "
|
||||
"Each rule can contain the following:"
|
||||
{ $subsections "peg.ebnf.strings"
|
||||
"peg.ebnf.any"
|
||||
"peg.ebnf.sequence"
|
||||
|
|
|
@ -48,7 +48,7 @@ ARTICLE: "inference-combinators" "Combinator stack effects"
|
|||
": perform ( value action -- result ) quot>> call( value -- result ) ;"
|
||||
}
|
||||
{ $subheading "Passing an unknown quotation to an inline combinator" }
|
||||
"Suppose we want to write :"
|
||||
"Suppose we want to write:"
|
||||
{ $code ": perform ( values action -- results ) quot>> map ;" }
|
||||
"However this fails to pass the stack checker since there is no guarantee the quotation has the right stack effect for " { $link map } ". It can be wrapped in a new quotation with a declaration:"
|
||||
{ $code ": perform ( values action -- results )" " quot>> [ call( value -- result ) ] curry map ;" }
|
||||
|
|
|
@ -323,7 +323,7 @@ HELP: assoc-stack
|
|||
|
||||
HELP: value-at*
|
||||
{ $values { "value" object } { "assoc" assoc } { "key/f" "the key associated to the value, or " { $link f } } { "?" boolean } }
|
||||
{ $description "Looks up the key associated with a value. The boolean flag can decide beteen the case of a missing key, and a key of " { $link f } "." } ;
|
||||
{ $description "Looks up the key associated with a value. The boolean flag can decide between the case of a missing key, and a key of " { $link f } "." } ;
|
||||
|
||||
HELP: value-at
|
||||
{ $values { "value" object } { "assoc" assoc } { "key/f" "the key associated to the value, or " { $link f } } }
|
||||
|
@ -438,7 +438,7 @@ HELP: assoc-map-as
|
|||
{ $values
|
||||
{ "assoc" assoc } { "quot" { $quotation "( ... key value -- ... newkey newvalue )" } } { "exemplar" assoc }
|
||||
{ "newassoc" assoc } }
|
||||
{ $description "Applies the quotation to each entry in the input assoc and collects the results in a new assoc of the stame type as the exemplar." }
|
||||
{ $description "Applies the quotation to each entry in the input assoc and collects the results in a new assoc of the same type as the exemplar." }
|
||||
{ $examples { $example "USING: prettyprint assocs hashtables math ;" " H{ { 1 2 } { 3 4 } } [ sq ] { } assoc-map-as ." "{ { 1 4 } { 3 16 } }" } } ;
|
||||
|
||||
HELP: extract-keys
|
||||
|
@ -457,7 +457,7 @@ HELP: push-at
|
|||
{ $values
|
||||
{ "value" object } { "key" object } { "assoc" assoc } }
|
||||
{ $description "Pushes the " { $snippet "value" } " onto a " { $snippet "vector" } " stored at the " { $snippet "key" } " in the " { $snippet "assoc" } ". If the " { $snippet "key" } " does not yet exist, creates a new " { $snippet "vector" } " at that " { $snippet "key" } " and pushes the " { $snippet "value" } "." }
|
||||
{ $examples { $example "USING: prettyprint assocs kernel ;"
|
||||
{ $examples { $example "USING: prettyprint assocs kernel ;"
|
||||
"H{ { \"cats\" V{ \"Mittens\" } } } \"Mew\" \"cats\" pick push-at ."
|
||||
"H{ { \"cats\" V{ \"Mittens\" \"Mew\" } } }"
|
||||
} } ;
|
||||
|
@ -467,7 +467,7 @@ HELP: search-alist
|
|||
{ "key" object } { "alist" "an array of key/value pairs" }
|
||||
{ "pair/f" "a key/value pair" } { "i/f" integer } }
|
||||
{ $description "Iterates over " { $snippet "alist" } " and stops when the key is matched or the end of the " { $snippet "alist" } " has been reached. If there is no match, both outputs are " { $link f } "." }
|
||||
{ $notes "This word is used to implement " { $link at* } " and " { $link set-at } " on sequences, and should not be called direclty." }
|
||||
{ $notes "This word is used to implement " { $link at* } " and " { $link set-at } " on sequences, and should not be called directly." }
|
||||
{ $examples { $example "USING: prettyprint assocs.private kernel ;"
|
||||
"3 { { 1 2 } { 3 4 } } search-alist [ . ] bi@"
|
||||
"{ 3 4 }\n1"
|
||||
|
|
|
@ -5,7 +5,7 @@ classes.predicate quotations ;
|
|||
IN: classes
|
||||
|
||||
ARTICLE: "class-predicates" "Class predicate words"
|
||||
"With a handful of exceptions, each class has a membership predicate word, named " { $snippet { $emphasis "class" } "?" } " . A quotation calling this predicate is stored in the " { $snippet "\"predicate\"" } " word property."
|
||||
"With a handful of exceptions, each class has a membership predicate word, named " { $snippet { $emphasis "class" } "?" } ". A quotation calling this predicate is stored in the " { $snippet "\"predicate\"" } " word property."
|
||||
$nl
|
||||
"When it comes to predicates, the exceptional classes are:"
|
||||
{ $table
|
||||
|
|
|
@ -326,12 +326,14 @@ HELP: cond
|
|||
}
|
||||
{ $errors "Throws a " { $link no-cond } " error if none of the test quotations yield a true value." }
|
||||
{ $examples
|
||||
{ $code
|
||||
"{"
|
||||
" { [ dup 0 > ] [ \"positive\" ] }"
|
||||
" { [ dup 0 < ] [ \"negative\" ] }"
|
||||
" [ \"zero\" ]"
|
||||
"} cond"
|
||||
{ $example
|
||||
"USING: combinators io kernel math ;"
|
||||
"0 {"
|
||||
" { [ dup 0 > ] [ drop \"positive\" ] }"
|
||||
" { [ dup 0 < ] [ drop \"negative\" ] }"
|
||||
" [ drop \"zero\" ]"
|
||||
"} cond print"
|
||||
"zero"
|
||||
}
|
||||
} ;
|
||||
|
||||
|
@ -340,7 +342,7 @@ HELP: no-cond
|
|||
{ $error-description "Thrown by " { $link cond } " if none of the test quotations yield a true value. Some uses of " { $link cond } " include a default case where the test quotation is " { $snippet "[ t ]" } "; such a " { $link cond } " form will never throw this error." } ;
|
||||
|
||||
HELP: case
|
||||
{ $values { "obj" object } { "assoc" "a sequence of object/word,quotation pairs, with an optional quotation at the end" } }
|
||||
{ $values { "obj" object } { "assoc" "a sequence of object/word, quotation pairs, with an optional quotation at the end" } }
|
||||
{ $description
|
||||
"Compares " { $snippet "obj" } " against the first element of every pair, first evaluating the first element if it is a word. If some pair matches, removes " { $snippet "obj" } " from the stack and calls the second element of that pair, which must be a quotation."
|
||||
$nl
|
||||
|
|
|
@ -265,7 +265,7 @@ HELP: return
|
|||
HELP: with-return
|
||||
{ $values
|
||||
{ "quot" quotation } }
|
||||
{ $description "Captures a continuation that can be reified by calling the " { $link return } " word. If so, it will resume execution immediatly after the " { $link with-return } " word. If " { $link return } " is not called, then execution proceeds as if this word were simply " { $link call } "." }
|
||||
{ $description "Captures a continuation that can be reified by calling the " { $link return } " word. If so, it will resume execution immediately after the " { $link with-return } " word. If " { $link return } " is not called, then execution proceeds as if this word were simply " { $link call } "." }
|
||||
{ $examples
|
||||
"Only \"Hi\" will print:"
|
||||
{ $example
|
||||
|
|
|
@ -716,7 +716,7 @@ HELP: MATH:
|
|||
{ $description "Defines a new generic word which uses the " { $link math-combination } " method combination." } ;
|
||||
|
||||
HELP: HOOK:
|
||||
{ $syntax "HOOK: word variable ( stack -- effect ) " }
|
||||
{ $syntax "HOOK: word variable ( stack -- effect )" }
|
||||
{ $values { "word" "a new word to define" } { "variable" word } }
|
||||
{ $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
|
||||
|
@ -850,7 +850,7 @@ HELP: C:
|
|||
"The following two lines are equivalent:"
|
||||
{ $code
|
||||
"C: <color> color"
|
||||
": <color> color boa ;"
|
||||
": <color> ( red green blue -- color ) color boa ;"
|
||||
}
|
||||
"In both cases, a word " { $snippet "<color>" } " is defined, which reads three values from the stack and creates a " { $snippet "color" } " instance having these values in the " { $snippet "red" } ", " { $snippet "green" } " and " { $snippet "blue" } " slots, respectively."
|
||||
} ;
|
||||
|
|
|
@ -165,7 +165,7 @@ ARTICLE: "words" "Words"
|
|||
$nl
|
||||
"There are two ways of creating word definitions:"
|
||||
{ $list
|
||||
"using parsing words at parse time,"
|
||||
"using parsing words at parse time."
|
||||
"using defining words at run time."
|
||||
}
|
||||
"The latter is a more dynamic feature that can be used to implement code generation and such, and in fact parse time defining words are implemented in terms of run time defining words."
|
||||
|
|
|
@ -95,7 +95,7 @@ $nl
|
|||
|
||||
|
||||
$nl
|
||||
"Utility words for displaying images :"
|
||||
"Utility words for displaying images:"
|
||||
{ $subsections
|
||||
image. image-window }
|
||||
|
||||
|
|
Loading…
Reference in New Issue