Merge branch 'master' of git://factorcode.org/git/factor

db4
Bruno Deferrari 2008-09-24 11:54:27 -03:00
commit aab5126d94
74 changed files with 206 additions and 34 deletions

View File

@ -46,6 +46,6 @@ ARTICLE: "ascii" "ASCII character classes"
{ $subsection printable? }
{ $subsection control? }
{ $subsection quotable? }
"Modern applications should use Unicode 5.0 instead (" { $vocab-link "unicode" } ")." ;
"Modern applications should use Unicode 5.0 instead (" { $vocab-link "unicode.categories" } ")." ;
ABOUT: "ascii"

View File

@ -1 +1 @@
extensions
concurrency

View File

@ -1 +1 @@
extensions
concurrency

View File

@ -19,7 +19,7 @@ HELP: SUPER->
ARTICLE: "objc-calling" "Calling Objective C code"
"Before an Objective C class can be used, it must be imported; by default, a small set of common classes are imported automatically, but additional classes can be imported as needed."
{ $subsection import-objc-class }
"Every imported Objective C class has as corresponding class word in the " { $vocab-link "objc-classes" } " vocabulary. Class words push the class object in the stack, allowing class methods to be invoked."
"Every imported Objective C class has as corresponding class word in the " { $vocab-link "cocoa.classes" } " vocabulary. Class words push the class object in the stack, allowing class methods to be invoked."
$nl
"Messages can be sent to classes and instances using a pair of parsing words:"
{ $subsection POSTPONE: -> }

View File

@ -4,7 +4,7 @@ kernel vectors arrays effects sequences ;
IN: compiler.generator
ARTICLE: "generator" "Compiled code generator"
"Most of the words in the " { $vocab-link "generator" } " vocabulary are internal to the compiler and user code has no reason to call them."
"Most of the words in the " { $vocab-link "compiler.generator" } " vocabulary are internal to the compiler and user code has no reason to call them."
$nl
"Debugging information can be enabled or disabled; this hook is used by " { $link "tools.deploy" } ":"
{ $subsection compiled-stack-traces? }

View File

@ -0,0 +1 @@
concurrency

View File

@ -0,0 +1 @@
concurrency

View File

@ -0,0 +1 @@
concurrency

View File

@ -1,2 +1,2 @@
concurrency
enterprise
extensions

View File

@ -0,0 +1 @@
concurrency

View File

@ -0,0 +1 @@
concurrency

View File

@ -0,0 +1 @@
concurrency

View File

@ -0,0 +1 @@
concurrency

View File

@ -0,0 +1 @@
concurrency

View File

@ -0,0 +1 @@
concurrency

View File

@ -0,0 +1 @@
concurrency

View File

@ -0,0 +1 @@
concurrency

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

1
basis/furnace/cache/tags.txt vendored Normal file
View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

1
basis/furnace/tags.txt Normal file
View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -312,13 +312,13 @@ ARTICLE: "cookbook-pitfalls" "Pitfalls to avoid"
{ "When a source file uses two vocabularies which define words with the same name, the order of the vocabularies in the " { $link POSTPONE: USE: } " or " { $link POSTPONE: USING: } " forms is important. The parser prints warnings when vocabularies shadow words from other vocabularies; see " { $link "vocabulary-search-shadow" } ". The " { $vocab-link "qualified" } " vocabulary implements qualified naming, which can be used to resolve ambiguities." }
{ "If a literal object appears in a word definition, the object itself is pushed on the stack when the word executes, not a copy. If you intend to mutate this object, you must " { $link clone } " it first. See " { $link "syntax-literals" } "." }
{ "For a discussion of potential issues surrounding the " { $link f } " object, see " { $link "booleans" } "." }
{ "Factor's object system is quite flexible. Careless usage of union, mixin and predicate classes can lead to similar problems to those caused by ``multiple inheritance'' in other languages. In particular, it is possible to have two classes such that they have a non-empty intersection and yet neither is a subclass of the other. If a generic word defines methods on two such classes, method precedence is undefined for objects that are instances of both classes. See " { $link "method-order" } " for details." }
{ "Factor's object system is quite flexible. Careless usage of union, mixin and predicate classes can lead to similar problems to those caused by ``multiple inheritance'' in other languages. In particular, it is possible to have two classes such that they have a non-empty intersection and yet neither is a subclass of the other. If a generic word defines methods on two such classes, various disambiguation rules are applied to ensure method dispatch remains deterministic, however they may not be what you expect. See " { $link "method-order" } " for details." }
{ "Performance-sensitive code should have a static stack effect so that it can be compiled by the optimizing word compiler, which generates more efficient code than the non-optimizing quotation compiler. See " { $link "inference" } " and " { $link "compiler" } "."
$nl
"This means that methods defined on performance sensitive, frequently-called core generic words such as " { $link nth } " should have static stack effects which are consistent with each other, since a generic word will only have a static stack effect if all methods do."
$nl
"Unit tests for the " { $vocab-link "inference" } " vocabulary can be used to ensure that any methods your vocabulary defines on core generic words have static stack effects:"
{ $code "\"inference\" test" }
"Unit tests for the " { $vocab-link "stack-checker" } " vocabulary can be used to ensure that any methods your vocabulary defines on core generic words have static stack effects:"
{ $code "\"stack-checker\" test" }
"In general, you should strive to write code with inferable stack effects, even for sections of a program which are not performance sensitive; the " { $link infer. } " tool together with the optimizing compiler's error reporting can catch many bugs ahead of time." }
{ "Be careful when calling words which access variables from a " { $link make-assoc } " which constructs an assoc with arbitrary keys, since those keys might shadow variables." }
{ "If " { $link run-file } " throws a stack depth assertion, it means that the top-level form in the file left behind values on the stack. The stack depth is compared before and after loading a source file, since this type of situation is almost always an error. If you have a legitimate need to load a source file which returns data in some manner, define a word in the source file which produces this data on the stack and call the word after loading the file." }

View File

@ -1,10 +1,10 @@
USING: help help.markup help.syntax help.definitions help.topics
namespaces words sequences classes assocs vocabs kernel arrays
prettyprint.backend kernel.private io generic math system
strings sbufs vectors byte-arrays
quotations io.streams.byte-array
classes.builtin parser lexer classes.predicate classes.union
classes.intersection classes.singleton classes.tuple ;
strings sbufs vectors byte-arrays quotations
io.streams.byte-array classes.builtin parser lexer
classes.predicate classes.union classes.intersection
classes.singleton classes.tuple tools.vocabs.browser ;
IN: help.handbook
ARTICLE: "conventions" "Conventions"
@ -139,7 +139,7 @@ ARTICLE: "collections" "Collections"
{ $subsection "heaps" }
{ $subsection "graphs" }
{ $subsection "buffers" }
"There are many other collections in " { $snippet "extra/" } ", such as " { $vocab-link "disjoint-sets" } ", " { $vocab-link "persistent-vectors" } ", and " { $vocab-link "tuple-arrays" } "." ;
"There are also many other vocabularies tagged " { $link T{ vocab-tag { name "collections" } } } " in the library." ;
USING: io.encodings.utf8 io.encodings.utf16 io.encodings.binary io.encodings.ascii io.files ;
@ -244,7 +244,8 @@ ARTICLE: "handbook-language-reference" "Language reference"
{ $subsection "program-org" }
{ $subsection "numbers" }
{ $subsection "collections" }
{ $subsection "io" } ;
{ $subsection "io" }
"Vocabularies tagged " { $link T{ vocab-tag { name "extensions" } } } " implement various additional language abstractions." ;
ARTICLE: "handbook-environment-reference" "Environment reference"
{ $subsection "prettyprint" }

View File

@ -61,10 +61,10 @@ IN: help.lint
: vocab-exists? ( name -- ? )
dup vocab swap "all-vocabs" get member? or ;
: check-modules ( word element -- )
nip \ $vocab-link swap elements [
: check-modules ( element -- )
\ $vocab-link swap elements [
second
vocab-exists? [ "Missing vocabulary" throw ] unless
vocab-exists? [ "$vocab-link to non-existent vocabulary" throw ] unless
] each ;
: check-rendering ( word element -- )
@ -91,7 +91,7 @@ M: help-error error.
2dup check-examples
2dup check-values
2dup check-see-also
2dup check-modules
2dup nip check-modules
2dup drop check-rendering
] assert-depth 2drop
] check-something
@ -101,12 +101,20 @@ M: help-error error.
: check-article ( article -- )
[
[ dup check-rendering ] assert-depth drop
dup article-content [
2dup check-modules check-rendering
] assert-depth 2drop
] check-something ;
: files>vocabs ( -- assoc )
vocabs
[ [ [ vocab-docs-path ] keep ] H{ } map>assoc ]
[ [ [ vocab-source-path ] keep ] H{ } map>assoc ]
bi assoc-union ;
: group-articles ( -- assoc )
articles get keys
vocabs [ dup vocab-docs-path swap ] H{ } map>assoc
files>vocabs
H{ } clone [
'[
dup >link where dup

View File

@ -9,7 +9,7 @@ xmode.code2html lcs.diff2html farkup
html.elements html.streams html.forms ;
IN: html.components
GENERIC: render* ( value name render -- )
GENERIC: render* ( value name renderer -- )
: render ( name renderer -- )
prepare-value

View File

@ -73,6 +73,7 @@ HELP: with-each-value
{ $notes "This word is used to implement the " { $snippet "t:each" } " tag of the " { $vocab-link "html.templates.chloe" } " templating system. It can also be called directly from " { $vocab-link "html.templates.fhtml" } " templates." } ;
HELP: with-each-object
{ $values { "name" string } { "quot" quotation } }
{ $description "Calls the quotation with each element of the value named " { $snippet "name" } "; the value must be a sequence. The quotation is called in a new dynamic scope where the object's slots become named values, as if " { $link from-object } " was called." }
{ $notes "This word is used to implement the " { $snippet "t:bind-each" } " tag of the " { $vocab-link "html.templates.chloe" } " templating system. It can also be called directly from " { $vocab-link "html.templates.fhtml" } " templates." } ;

View File

@ -18,6 +18,7 @@ HELP: with-html-stream
{ $description "Calls the quotation in a new dynamic scope with " { $link output-stream } " rebound to an " { $link html-stream } " wrapping the current " { $link output-stream } "." }
{ $examples
{ $example
"USING: io io.styles html.streams ;"
"[ \"Hello\" { { font-style bold } } format nl ] with-html-stream"
"<span style='font-style: normal; font-weight: bold; '>Hello</span><br/>"
}

View File

@ -28,7 +28,6 @@ HELP: set-title
{ $description "Sets the title of the current page. This is usually called by child templates, and a master template calls " { $link write-title } "." } ;
HELP: write-title
{ $values { "string" string } }
{ $description "Writes the title of the current page, previously set by " { $link set-title } ". This is usually called by a master template after rendering a child template." } ;
HELP: add-style

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -1,3 +1,3 @@
web
enterprise
network
web

View File

@ -8,7 +8,7 @@ $nl
$nl
"Buffers are used to implement native I/O backends."
$nl
"Buffer words are found in the " { $vocab-link "buffers" } " vocabulary."
"Buffer words are found in the " { $vocab-link "io.buffers" } " vocabulary."
{ $subsection buffer }
{ $subsection <buffer> }
"Buffers must be manually deallocated by calling " { $link dispose } "."

View File

@ -36,7 +36,7 @@ ARTICLE: "presentations" "Presentations"
ARTICLE: "styles" "Formatted output"
"The " { $link stream-format } ", " { $link with-style } ", " { $link with-nesting } " and " { $link tabular-output } " words take a hashtable of style attributes. Output stream implementations are free to ignore style information."
$nl
"Style hashtables are keyed by symbols from the " { $vocab-link "styles" } " vocabulary."
"Style hashtables are keyed by symbols from the " { $vocab-link "io.styles" } " vocabulary."
{ $subsection "character-styles" }
{ $subsection "paragraph-styles" }
{ $subsection "table-styles" }

View File

@ -20,7 +20,7 @@ HELP: analyze-log
{ $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"
"The " { $vocab-link "logging.analysis" } " vocabulary builds on the " { $vocab-link "logging.parser" } " vocabulary. It parses log files and produces formatted summary reports. It is used by the " { $vocab-link "logger.insomniac" } " vocabulary to e-mail daily reports."
"The " { $vocab-link "logging.analysis" } " vocabulary builds on the " { $vocab-link "logging.parser" } " vocabulary. It parses log files and produces formatted summary reports. It is used by the " { $vocab-link "logging.insomniac" } " vocabulary to e-mail daily reports."
$nl
"Print log file summary:"
{ $subsection analyze-log }

View File

@ -100,7 +100,7 @@ ARTICLE: "logging.rotation" "Log rotation"
"The " { $vocab-link "logging.insomniac" } " vocabulary automates log rotation." ;
ARTICLE: "logging.server" "Log implementation"
"The " { $vocab-link "logging.server" } " vocabulary implements a concurrent log server using " { $vocab-link "concurrency" } ". User code never interacts with the server directly, instead it uses the words in the " { $link "logging" } " vocabulary. The server is used to synchronize access to log files and ensure that log rotation can proceed in an orderly fashion."
"The " { $vocab-link "logging.server" } " vocabulary implements a concurrent log server using " { $vocab-link "concurrency.messaging" } ". User code never interacts with the server directly, instead it uses the words in the " { $link "logging" } " vocabulary. The server is used to synchronize access to log files and ensure that log rotation can proceed in an orderly fashion."
$nl
"The " { $link log-message } " word sends a message to the server which results in the server executing an internal word:"
{ $subsection (log-message) }

1
basis/symbols/tags.txt Normal file
View File

@ -0,0 +1 @@
extensions

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1,110 @@
USING: help.markup help.syntax io.streams.string quotations
strings math parser-combinators.regexp ;
IN: validators
HELP: v-captcha
{ $values { "str" string } }
{ $description "Throws a validation error if the string is non-empty. This is used to create bait fields for spam-bots to fill in." } ;
HELP: v-credit-card
{ $values { "str" string } { "n" integer } }
{ $description "If the credit card number passes the Luhn algorithm, converts it to an integer, otherwise throws an error." }
{ $notes "See " { $url "http://en.wikipedia.org/wiki/Luhn_algorithm" } " for a description of this algorithm." } ;
HELP: v-default
{ $values { "str" string } { "def" string } { "str/def" string } }
{ $description "If the input string is not specified, replaces it with the default value." } ;
HELP: v-email
{ $values { "str" string } }
{ $description "Throws a validation error if the string is not a valid e-mail address, as determined by a regular expression." } ;
HELP: v-integer
{ $values { "str" string } { "n" integer } }
{ $description "Converts the string into an integer, throwing a validation error if the string is not a valid integer." } ;
HELP: v-min-length
{ $values { "str" string } { "n" integer } }
{ $description "Throws a validation error if the string is shorter than " { $snippet "n" } " characters." } ;
HELP: v-max-length
{ $values { "str" string } { "n" integer } }
{ $description "Throws a validation error if the string is longer than " { $snippet "n" } " characters." } ;
HELP: v-max-value
{ $values { "x" integer } { "n" integer } }
{ $description "Throws an error if " { $snippet "x" } " is larger than " { $snippet "n" } "." } ;
HELP: v-min-value
{ $values { "x" integer } { "n" integer } }
{ $description "Throws an error if " { $snippet "x" } " is smaller than " { $snippet "n" } "." } ;
HELP: v-mode
{ $values { "str" string } }
{ $description "Throws an error if " { $snippet "str" } " is not a valid XMode mode name." } ;
HELP: v-number
{ $values { "str" string } { "n" real } }
{ $description "Converts the string into a real number, throwing a validation error if the string is not a valid real number." } ;
HELP: v-one-line
{ $values { "str" string } }
{ $description "Throws a validation error if the string contains line breaks." } ;
HELP: v-one-word
{ $values { "str" string } }
{ $description "Throws a validation error if the string contains word breaks." } ;
HELP: v-optional
{ $values { "str" string } { "quot" quotation } { "result" string } }
{ $description "If the string is non-empty, applies the quotation to the string, otherwise outputs the empty string." } ;
HELP: v-password
{ $values { "str" string } }
{ $description "A reasonable default validator for passwords." } ;
HELP: v-regexp
{ $values { "str" string } { "what" string } { "regexp" regexp } }
{ $description "Throws a validation error that " { $snippet "what" } " failed if the string does not match the regular expression." } ;
HELP: v-required
{ $values { "str" string } }
{ $description "Throws a validation error if the string is empty." } ;
HELP: v-url
{ $values { "str" string } }
{ $description "Throws an error if the string is not a valid URL, as determined by a regular expression." } ;
HELP: v-username
{ $values { "str" string } }
{ $description "A reasonable default validator for usernames." } ;
ARTICLE: "validators" "Form validators"
"The " { $vocab-link "validators" } " vocabulary provides a set of words which are intended to be used with the form validation functionality offered by " { $vocab-link "furnace.actions" } ". They can also be used independently of the web framework."
$nl
"Note that validators which take numbers must be preceded by " { $link v-integer } " or " { $link v-number } " if the original input is a string."
$nl
"Higher-order validators which require additional parameters:"
{ $subsection v-default }
{ $subsection v-optional }
{ $subsection v-min-length }
{ $subsection v-max-length }
{ $subsection v-min-value }
{ $subsection v-max-value }
{ $subsection v-regexp }
"Simple validators:"
{ $subsection v-required }
{ $subsection v-number }
{ $subsection v-integer }
{ $subsection v-one-line }
{ $subsection v-one-word }
{ $subsection v-captcha }
"More complex validators:"
{ $subsection v-email }
{ $subsection v-url }
{ $subsection v-username }
{ $subsection v-password }
{ $subsection v-credit-card }
{ $subsection v-mode } ;
ABOUT: "validators"

View File

@ -6,13 +6,13 @@ unicode.categories arrays hashtables words classes quotations
xmode.catalog ;
IN: validators
: v-default ( str def -- str )
: v-default ( str def -- str/def )
over empty? spin ? ;
: v-required ( str -- str )
dup empty? [ "required" throw ] when ;
: v-optional ( str quot -- str )
: v-optional ( str quot -- result )
over empty? [ 2drop f ] [ call ] if ; inline
: v-min-length ( str n -- str )
@ -91,7 +91,7 @@ IN: validators
"not a valid syntax mode" throw
] unless ;
: luhn? ( n -- ? )
: luhn? ( str -- ? )
string>digits <reversed>
[ odd? [ 2 * 10 /mod + ] when ] map-index
sum 10 mod 0 = ;

View File

@ -23,7 +23,8 @@ $nl
"Since strings are sequences, basic string manipulation can be performed using sequence operations (" { $link "sequences" } "). More advanced functionality can be found in other vocabularies, including but not limited to:"
{ $list
{ { $vocab-link "ascii" } " - traditional ASCII character classes" }
{ { $vocab-link "unicode" } " - Unicode 5.0-aware character classes, case conversion, word breaks, ..." }
{ { $vocab-link "unicode.categories" } " - Unicode character classes" }
{ { $vocab-link "unicode.case" } " - Unicode case conversion" }
{ { $vocab-link "regexp" } " - regular expressions" }
{ { $vocab-link "peg" } " - parser expression grammars" }
} ;

View File

@ -39,7 +39,7 @@ HELP: sprintf
{ $see-also printf } ;
ARTICLE: "printf" "Formatted printing"
"The " { $vocab-link "printf" } " and " { $vocab-link "sprintf" } " words are used for formatted printing.\n"
"The " { $link printf } " and " { $link sprintf } " words are used for formatted printing.\n"
"\n"
"Several format specifications exist for handling arguments of different types, and specifying attributes for the result string, including such things as maximum width, padding, and decimals.\n"
{ $table

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -0,0 +1 @@
web

View File

@ -42,6 +42,6 @@ HELP: wordtimer-call
ARTICLE: "wordtimer" "Word Timer"
"The " { $vocab-link "wordtimer" } " vocabulary measures accumulated execution time for words. If you just want to profile the accumulated time taken by all words in a vocab you can use " { $vocab-link "profile-vocab" } ". If you need more fine grained control then do the following: First annotate individual words with the " { $link add-timer } " word or whole vocabularies with " { $link add-timers } ". Then use " { $link wordtimer-call } " to invoke a quotation and print out the timings." ;
"The " { $vocab-link "wordtimer" } " vocabulary measures accumulated execution time for words. If you just want to profile the accumulated time taken by all words in a vocab you can use " { $link profile-vocab } ". If you need more fine grained control then do the following: First annotate individual words with the " { $link add-timer } " word or whole vocabularies with " { $link add-timers } ". Then use " { $link wordtimer-call } " to invoke a quotation and print out the timings." ;
ABOUT: "wordtimer"