Merge branch 'master' of git://github.com/slavapestov/factor

db4
John Benediktsson 2010-12-13 12:47:10 -08:00
commit de155315bd
9 changed files with 113 additions and 87 deletions

View File

@ -8,7 +8,7 @@ HELP: send
{ $values { "message" object } { $values { "message" object }
{ "thread" thread } { "thread" thread }
} }
{ $description "Send the message to the thread by placing it in the threads 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." } { $description "Send the message to the thread by placing it in the threads mailbox. This is an asynchronous operation and will return immediately. The receiving 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 } ; { $see-also receive receive-if } ;
HELP: receive HELP: receive

View File

@ -233,8 +233,7 @@ T{ book
{ date-published T{ timestamp { year 2009 } { month 3 } { day 3 } } } { date-published T{ timestamp { year 2009 } { month 3 } { day 3 } } }
{ edition 1 } { edition 1 }
{ cover-price 13.37 } { cover-price 13.37 }
} book set } book set""" }
""" }
"Now we've created a book. Let's save it to the database." "Now we've created a book. Let's save it to the database."
{ $code """USING: db db.sqlite fry io.files.temp ; { $code """USING: db db.sqlite fry io.files.temp ;
: with-book-tutorial ( quot -- ) : with-book-tutorial ( quot -- )
@ -243,8 +242,7 @@ T{ book
[ [
book recreate-table book recreate-table
book get insert-tuple book get insert-tuple
] with-book-tutorial ] with-book-tutorial""" }
""" }
"Is it really there?" "Is it really there?"
{ $code """[ { $code """[
T{ book { title "Factor for Sheeple" } } select-tuples . T{ book { title "Factor for Sheeple" } } select-tuples .

View File

@ -476,7 +476,7 @@ HELP: HELP:
{ $description "Defines documentation for a word." } { $description "Defines documentation for a word." }
{ $examples { $examples
{ $code { $code
"USING: help help.markup help.syntax math syntax ;" "USING: help help.markup help.syntax math ;"
": foo ( m -- n ) 2 + ;" ": foo ( m -- n ) 2 + ;"
"HELP: foo" "HELP: foo"
"{ $values { \"m\" \"an integer\" } { \"n\" \"an integer\" } }" "{ $values { \"m\" \"an integer\" } { \"n\" \"an integer\" } }"

View File

@ -27,13 +27,12 @@ $nl
{ $examples { $examples
"The " { $link append } " word has a specializer for the very common case where two strings or two arrays are appended:" "The " { $link append } " word has a specializer for the very common case where two strings or two arrays are appended:"
{ $code { $code
"USING: arrays hints sequences strings syntax ;" "USING: arrays hints sequences strings ;"
"HINTS: append { string string } { array array } ;" "HINTS: append { string string } { array array } ;"
} }
"Specializers can also be defined on methods:" "Specializers can also be defined on methods:"
{ $code { $code
"USING: assocs hashtables hints kernel sequences" "USING: assocs hashtables hints kernel sequences ;"
"syntax ;"
"GENERIC: count-occurrences ( elt obj -- n )" "GENERIC: count-occurrences ( elt obj -- n )"
"" ""
"M: sequence count-occurrences [ = ] with count ;" "M: sequence count-occurrences [ = ] with count ;"

View File

@ -61,6 +61,7 @@ $nl
"The " { $snippet "style" } " hashtable holds table style information. See " { $link "table-styles" } "." } "The " { $snippet "style" } " hashtable holds table style information. See " { $link "table-styles" } "." }
{ $examples { $examples
{ $code { $code
"USING: io.styles prettyprint sequences ;"
"{ { 1 2 } { 3 4 } }" "{ { 1 2 } { 3 4 } }"
"H{ { table-gap { 10 10 } } } [" "H{ { table-gap { 10 10 } } } ["
" [ [ [ [ . ] with-cell ] each ] with-row ] each" " [ [ [ [ . ] with-cell ] each ] with-row ] each"
@ -204,6 +205,7 @@ HELP: foreground
{ $description "Character style. An instance of " { $link color } ". See " { $link "colors" } "." } { $description "Character style. An instance of " { $link color } ". See " { $link "colors" } "." }
{ $examples { $examples
{ $code { $code
"USING: colors.gray io.styles hashtables sequences kernel math ;"
"10 iota [" "10 iota ["
" \"Hello world\\n\"" " \"Hello world\\n\""
" swap 10 / 1 <gray> foreground associate format" " swap 10 / 1 <gray> foreground associate format"
@ -215,6 +217,7 @@ HELP: background
{ $description "Character style. An instance of " { $link color } ". See " { $link "colors" } "." } { $description "Character style. An instance of " { $link color } ". See " { $link "colors" } "." }
{ $examples { $examples
{ $code { $code
"USING: colors hashtables io io.styles kernel math sequences ;"
"10 iota [" "10 iota ["
" \"Hello world\\n\"" " \"Hello world\\n\""
" swap 10 / 1 over - over 1 <rgba>" " swap 10 / 1 over - over 1 <rgba>"
@ -227,14 +230,20 @@ HELP: font-name
{ $description "Character style. Font family named by a string." } { $description "Character style. Font family named by a string." }
{ $examples { $examples
"This example outputs some different font sizes:" "This example outputs some different font sizes:"
{ $code "{ \"monospace\" \"serif\" \"sans-serif\" }\n[ dup font-name associate format nl ] each" } { $code
"USING: hashtables io io.styles kernel sequences ;"
"{ \"monospace\" \"serif\" \"sans-serif\" }"
"[ dup font-name associate format nl ] each"
}
} ; } ;
HELP: font-size HELP: font-size
{ $description "Character style. Font size, an integer." } { $description "Character style. Font size, an integer." }
{ $examples { $examples
"This example outputs some different font sizes:" "This example outputs some different font sizes:"
{ $code "{ 12 18 24 72 }" { $code
"USING: hashtables io io.styles kernel sequences ;"
"{ 12 18 24 72 }"
"[ \"Bigger\" swap font-size associate format nl ] each" "[ \"Bigger\" swap font-size associate format nl ] each"
} }
} ; } ;
@ -243,7 +252,11 @@ HELP: font-style
{ $description "Character style. Font style, one of " { $link plain } ", " { $link bold } ", " { $link italic } ", or " { $link bold-italic } "." } { $description "Character style. Font style, one of " { $link plain } ", " { $link bold } ", " { $link italic } ", or " { $link bold-italic } "." }
{ $examples { $examples
"This example outputs text in all three styles:" "This example outputs text in all three styles:"
{ $code "{ plain bold italic bold-italic }\n[ [ name>> ] keep font-style associate format nl ] each" } { $code
"USING: accessors hashtables io io.styles kernel sequences ;"
"{ plain bold italic bold-italic }"
"[ [ name>> ] keep font-style associate format nl ] each"
}
} ; } ;
HELP: presented HELP: presented
@ -252,19 +265,31 @@ HELP: presented
HELP: page-color HELP: page-color
{ $description "Paragraph style. An instance of " { $link color } ". See " { $link "colors" } "." } { $description "Paragraph style. An instance of " { $link color } ". See " { $link "colors" } "." }
{ $examples { $examples
{ $code "H{ { page-color T{ rgba f 1 0.8 0.5 1 } } }\n[ \"A background\" write ] with-nesting nl" } { $code
"USING: colors io io.styles ;"
"H{ { page-color T{ rgba f 1 0.8 0.5 1 } } }"
"[ \"A background\" write ] with-nesting nl"
}
} ; } ;
HELP: border-color HELP: border-color
{ $description "Paragraph style. An instance of " { $link color } ". See " { $link "colors" } "." } { $description "Paragraph style. An instance of " { $link color } ". See " { $link "colors" } "." }
{ $examples { $examples
{ $code "H{ { border-color T{ rgba f 1 0 0 1 } } }\n[ \"A border\" write ] with-nesting nl" } { $code
"USING: colors io io.styles ;"
"H{ { border-color T{ rgba f 1 0 0 1 } } }"
"[ \"A border\" write ] with-nesting nl"
}
} ; } ;
HELP: inset HELP: inset
{ $description "Paragraph style. A pair of integers representing the number of pixels that the content should be inset from the border. The first number is the horizontal inset, and the second is the vertical inset." } { $description "Paragraph style. A pair of integers representing the number of pixels that the content should be inset from the border. The first number is the horizontal inset, and the second is the vertical inset." }
{ $examples { $examples
{ $code "H{ { inset { 10 10 } } }\n[ \"Some inset text\" write ] with-nesting nl" } { $code
"USING: io io.styles ;"
"H{ { inset { 10 10 } } }"
"[ \"Some inset text\" write ] with-nesting nl"
}
} ; } ;
HELP: wrap-margin HELP: wrap-margin
@ -284,7 +309,10 @@ HELP: input
{ $class-description "Class of input text presentations. Instances can be used passed to " { $link write-object } " to output a clickable piece of input. Input text presentations are created by calling " { $link <input> } "." } { $class-description "Class of input text presentations. Instances can be used passed to " { $link write-object } " to output a clickable piece of input. Input text presentations are created by calling " { $link <input> } "." }
{ $examples { $examples
"This presentation class is used for the code examples you see in the online help:" "This presentation class is used for the code examples you see in the online help:"
{ $code "\"2 3 + .\" dup <input> write-object nl" } { $code
"USING: io io.styles kernel ;"
"\"2 3 + .\" dup <input> write-object nl"
}
} ; } ;
HELP: <input> HELP: <input>

View File

@ -8,23 +8,22 @@ HELP: $
{ $description "Executes " { $snippet "word" } " at parse time and adds the result(s) to the parser accumulator." } { $description "Executes " { $snippet "word" } " at parse time and adds the result(s) to the parser accumulator." }
{ $notes { $snippet "word" } "'s definition is looked up and " { $link call } "ed at parse time, so words that reference words in the current compilation unit cannot be used with " { $snippet "$" } "." } { $notes { $snippet "word" } "'s definition is looked up and " { $link call } "ed at parse time, so words that reference words in the current compilation unit cannot be used with " { $snippet "$" } "." }
{ $examples { $examples
{ $example
{ $example """ "USING: kernel literals prettyprint ;"
USING: kernel literals prettyprint ; "IN: scratchpad"
IN: scratchpad ""
"CONSTANT: five 5"
CONSTANT: five 5 "{ $ five } ."
{ $ five } . "{ 5 }"
""" "{ 5 }" } }
{ $example
{ $example """ "USING: kernel literals prettyprint ;"
USING: kernel literals prettyprint ; "IN: scratchpad"
IN: scratchpad ""
": seven-eleven ( -- a b ) 7 11 ;"
: seven-eleven ( -- a b ) 7 11 ; "{ $ seven-eleven } ."
{ $ seven-eleven } . "{ 7 11 }"
""" "{ 7 11 }" } }
} ; } ;
HELP: $[ HELP: $[
@ -32,15 +31,14 @@ HELP: $[
{ $description "Calls " { $snippet "code" } " at parse time and adds the result(s) to the parser accumulator." } { $description "Calls " { $snippet "code" } " at parse time and adds the result(s) to the parser accumulator." }
{ $notes "Since " { $snippet "code" } " is " { $link call } "ed at parse time, it cannot reference any words defined in the same compilation unit." } { $notes "Since " { $snippet "code" } " is " { $link call } "ed at parse time, it cannot reference any words defined in the same compilation unit." }
{ $examples { $examples
{ $example
{ $example """ "USING: kernel literals math prettyprint ;"
USING: kernel literals math prettyprint ; "IN: scratchpad"
IN: scratchpad ""
"<< CONSTANT: five 5 >>"
<< CONSTANT: five 5 >> "{ $[ five dup 1 + dup 2 + ] } ."
{ $[ five dup 1 + dup 2 + ] } . "{ 5 6 8 }"
""" "{ 5 6 8 }" } }
} ; } ;
HELP: ${ HELP: ${
@ -48,15 +46,14 @@ HELP: ${
{ $description "Outputs an array containing the results of executing " { $snippet "code" } " at parse time." } { $description "Outputs an array containing the results of executing " { $snippet "code" } " at parse time." }
{ $notes { $snippet "code" } "'s definition is looked up and " { $link call } "ed at parse time, so words that reference words in the current compilation unit cannot be used with " { $snippet "$" } "." } { $notes { $snippet "code" } "'s definition is looked up and " { $link call } "ed at parse time, so words that reference words in the current compilation unit cannot be used with " { $snippet "$" } "." }
{ $examples { $examples
{ $example
{ $example """ "USING: kernel literals math prettyprint ;"
USING: kernel literals math prettyprint ; "IN: scratchpad"
IN: scratchpad ""
"CONSTANT: five 5"
CONSTANT: five 5 "CONSTANT: six 6"
CONSTANT: six 6 "${ five six 7 } ."
${ five six 7 } . "{ 5 6 7 }"
""" "{ 5 6 7 }"
} }
} ; } ;
@ -66,7 +63,8 @@ HELP: flags{
{ $values { "values" sequence } } { $values { "values" sequence } }
{ $description "Constructs a constant flag value from a sequence of integers or words that output integers. The resulting constant is computed at parse-time, which makes this word as efficient as using a literal integer." } { $description "Constructs a constant flag value from a sequence of integers or words that output integers. The resulting constant is computed at parse-time, which makes this word as efficient as using a literal integer." }
{ $examples { $examples
{ $example "USING: literals kernel prettyprint ;" { $example
"USING: literals kernel prettyprint ;"
"IN: scratchpad" "IN: scratchpad"
"CONSTANT: x HEX: 1" "CONSTANT: x HEX: 1"
"flags{ HEX: 20 x BIN: 100 } .h" "flags{ HEX: 20 x BIN: 100 } .h"
@ -77,13 +75,14 @@ HELP: flags{
ARTICLE: "literals" "Interpolating code results into literal values" ARTICLE: "literals" "Interpolating code results into literal values"
"The " { $vocab-link "literals" } " vocabulary contains words to run code at parse time and insert the results into more complex literal values." "The " { $vocab-link "literals" } " vocabulary contains words to run code at parse time and insert the results into more complex literal values."
{ $example """ { $example
USE: literals "USING: kernel literals math prettyprint ;"
IN: scratchpad "IN: scratchpad"
""
CONSTANT: five 5 "<< CONSTANT: five 5 >>"
{ $ five $[ five dup 1 + dup 2 + ] } . "{ $ five $[ five dup 1 + dup 2 + ] } ."
""" "{ 5 5 6 8 }" } "{ 5 5 6 8 }"
}
{ $subsections { $subsections
POSTPONE: $ POSTPONE: $
POSTPONE: $[ POSTPONE: $[

View File

@ -1,4 +1,4 @@
USING: strings help.markup help.syntax assocs ; USING: strings help.markup help.syntax assocs urls ;
IN: urls.encoding IN: urls.encoding
HELP: url-decode HELP: url-decode

View File

@ -215,12 +215,14 @@ ARTICLE: "tuple-examples" "Tuple examples"
{ $table { $table
{ "Reader" "Writer" "Setter" "Changer" } { "Reader" "Writer" "Setter" "Changer" }
{ { $snippet "name>>" } { $snippet "name<<" } { $snippet ">>name" } { $snippet "change-name" } } { { $snippet "name>>" } { $snippet "name<<" } { $snippet ">>name" } { $snippet "change-name" } }
{ { $snippet "salary>>" } { $snippet "salary<<" } { $snippet ">>salary" } { $snippet "change-salary" } }
{ { $snippet "position>>" } { $snippet "position<<" } { $snippet ">>position" } { $snippet "change-position" } } { { $snippet "position>>" } { $snippet "position<<" } { $snippet ">>position" } { $snippet "change-position" } }
{ { $snippet "salary>>" } { $snippet "salary<<" } { $snippet ">>salary" } { $snippet "change-salary" } }
} }
"We can define a constructor which makes an empty employee:" "We can define a constructor which makes an empty employee:"
{ $code ": <employee> ( -- employee )" { $code
" employee new ;" } ": <employee> ( -- employee )"
" employee new ;"
}
"Or we may wish the default constructor to always give employees a starting salary:" "Or we may wish the default constructor to always give employees a starting salary:"
{ $code { $code
": <employee> ( -- employee )" ": <employee> ( -- employee )"

View File

@ -129,7 +129,7 @@ HELP: define-generic
HELP: M\ HELP: M\
{ $syntax "M\\ class generic" } { $syntax "M\\ class generic" }
{ $class-description "Pushes a method on the stack." } { $class-description "Pushes a method on the stack." }
{ $examples { $code "M\\ fixnum + see" } { $code "USING: ui.gadgets ui.gadgets.editors ;" "M\\ editor draw-gadget* edit" } } ; { $examples { $code "M\\ fixnum + see" } { $code "USING: ui.gadgets.editors ui.render ;" "M\\ editor draw-gadget* edit" } } ;
HELP: method HELP: method
{ $values { "class" class } { "generic" generic } { "method/f" { $maybe method } } } { $values { "class" class } { "generic" generic } { "method/f" { $maybe method } } }