HELP: <buffer>
{ $values { "n" "a non-negative integer" } { "buffer" buffer } }
-{ $description "Creates a buffer with an initial capacity of " { $snippet "n" } " bytes." } ;
+{ $description "Allocates a buffer with an initial capacity of " { $snippet "n" } " bytes." } ;
HELP: buffer-reset
{ $values { "n" "a non-negative integer" } { "buffer" buffer } }
{ $description "Collects a byte array of " { $snippet "n" } " bytes starting from the buffer's current position, and advances the position accordingly. If there are less than " { $snippet "n" } " bytes available, the output is truncated." }
{ $examples
{ $example
- "USING: io.buffers ;"
- "5 100 <buffer> B{ 7 14 21 } over >buffer buffer-read ."
+ "USING: destructors io.buffers kernel prettyprint ;"
+ "5 100 <buffer> [ B{ 7 14 21 } over >buffer buffer-read ] with-disposal ."
"B{ 7 14 21 }"
}
} ;
{ $description "Outputs the number of unconsumed bytes in the buffer." }
{ $examples
{ $example
- "USING: io.buffers ;"
- "100 <buffer> B{ 7 14 21 } over >buffer buffer-length ."
+ "USING: destructors io.buffers kernel prettyprint ;"
+ "100 <buffer> [ B{ 7 14 21 } over >buffer buffer-length ] with-disposal ."
"3"
}
} ;
{ $description "Outputs the buffer's maximum capacity before growing." }
{ $examples
{ $example
- "USING: io.buffers ;"
- "100 <buffer> buffer-capacity ."
+ "USING: destructors io.buffers prettyprint ;"
+ "100 <buffer> [ buffer-capacity ] with-disposal ."
"100"
}
} ;
{ $warning "This word will corrupt memory if the buffer is full." }
{ $examples
{ $example
- "USING: io.buffers ;"
- "100 <buffer> 237 over byte>buffer buffer-pop ."
+ "USING: destructors io.buffers kernel prettyprint ;"
+ "100 <buffer> [ 237 over byte>buffer buffer-pop ] with-disposal ."
"237"
}
} ;
{ $values { "path" "a filesystem path" } { "win32-file" "a win32 file-handle" } }
{ $description "Opens a file for reading and returns a filehandle to it." }
{ $examples
- { $example
- "USING: io.files.windows ;"
+ { $unchecked-example
+ "USING: io.files.windows prettyprint ;"
"\"resource:core/kernel/kernel.factor\" absolute-path open-read ."
"T{ win32-file { handle ALIEN: 234 } { ptr 0 } }"
}
! Copyright (C) 2007, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: help.markup help.syntax quotations kernel io io.files
-math calendar ;
+USING: calendar help.markup help.syntax io io.files kernel literals math
+quotations sequences ;
IN: io.launcher
ARTICLE: "io.launcher.command" "Specifying a command"
{ $description "Returns the handle of the current process." }
{ $examples
{ $example
- "USING: io.launcher ;"
- "current-process-handle ."
- "6881"
+ "USING: io.launcher math prettyprint ;"
+ "current-process-handle number? ."
+ "t"
}
} ;
{ $description "Launches a process. The object can either be a string, a sequence of strings or a " { $link process } ". See " { $link "io.launcher.descriptors" } " for details." }
{ $examples
{ $example
- "USING: io.launcher ;"
+ "USING: io.launcher prettyprint ;"
"\"pwd\" run-process ."
- "/tmp"
- "T{ process"
- " { command \"pwd\" }"
- " { environment H{ } }"
- " { environment-mode +append-environment+ }"
- " { group +same-group+ }"
- " { status 0 }"
- "}"
+ "T{ process\n { command \"pwd\" }\n { environment H{ } }\n { environment-mode +append-environment+ }\n { group +same-group+ }\n { status 0 }\n}"
}
}
{ $notes "The output value can be passed to " { $link wait-for-process } " to get an exit code." } ;
{ $description "Launches a process and waits for it to complete. If it exits with a non-zero status code, throws a " { $link process-failed } " error." }
{ $examples
{ $example
- "USING: continuations io.launcher ;"
- "[ \"ls --invalid-flag\" try-process ] [ ] recover ."
- "ls: unknown flag \"--invalid-flag\""
- "Try with ”ls --help” for more information."
- "T{ process-failed"
- " { process"
- " T{ process"
- " { command \"ls --invalid-flag\" }"
- " { environment H{ } }"
- " { environment-mode +append-environment+ }"
- " { group +same-group+ }"
- " { status 2 }"
- " }"
- "}"
+ "USING: continuations io.launcher prettyprint ;"
+ "[ \"i-dont-exist\" try-process ] [ ] recover ."
+ $[
+ {
+ "T{ process-failed"
+ " { process"
+ " T{ process"
+ " { command \"i-dont-exist\" }"
+ " { environment H{ } }"
+ " { environment-mode +append-environment+ }"
+ " { group +same-group+ }"
+ " { status 255 }"
+ " }"
+ " }"
+ "}"
+ } "\n" join
+ ]
}
} ;
{ $example
"USING: io.launcher ;"
"\"cat\" run-detached kill-process"
+ ""
}
} ;
}
{ $description "Launches a process and redirects its output via a pipe. The quotation is called with " { $link input-stream } " and " { $link output-stream } " rebound to this pipe." }
{ $examples
- { $example
- "USING: io.launcher ;"
+ { $unchecked-example
+ "USING: io.launcher prettyprint ;"
"\"ls -dl /etc\" utf8 [ contents ] with-process-reader ."
"\"drwxr-xr-x 213 root root 12288 mar 11 18:52 /etc\\n\""
}
{ $values { "dt/f" { $maybe duration } } { "obj" object } }\r
{ $contract "Sets an object's timeout." }\r
{ $examples "Waits five seconds for a process that sleeps for ten seconds:"\r
- { $example\r
- "USING: calendar io.launcher io.timeouts ;"\r
+ { $unchecked-example\r
+ "USING: calendar io.launcher io.timeouts kernel ;"\r
"\"sleep 10\" >process 5 seconds over set-timeout run-process"\r
"Process was killed as a result of a call to"\r
"kill-process, or a timeout"\r
IN: math.matrices.elimination
HELP: inverse
-{ $values { "matrix" sequence } { "matrix" sequence } }
+{ $values { "matrix" sequence } }
{ $description "Computes the multiplicative inverse of a matrix. Assuming the matrix is invertible." }
{ $examples
"A matrix multiplied by its inverse is the identity matrix."
{ $example
- "USING: math.matrices math.matrices.elimination prettyprint ;"
+ "USING: kernel math.matrices math.matrices.elimination prettyprint ;"
"{ { 3 4 } { 7 9 } } dup inverse m. 2 identity-matrix = ."
"t"
}
USING: help.markup help.syntax math sequences ;
-
IN: math.matrices
HELP: zero-matrix
{ $description "Creates an identity matrix of size " { $snippet "n x n" } ", where the diagonal values are all ones." } ;
HELP: m.v
-{ $values { "m" sequence } { "v" sequence } { "v" sequence } }
+{ $values { "m" sequence } { "v" sequence } }
{ $description "Computes the dot product between a matrix and a vector." }
{ $examples
{ $example
} ;
HELP: m.
-{ $values { "m" sequence } { "m" sequence } { "m" sequence } }
+{ $values { "m" sequence } }
{ $description "Computes the dot product between two matrices, i.e multiplies them." }
{ $examples
{ $example
} ;
HELP: m+
-{ $values { "m" sequence } { "m" sequence } { "m" sequence } }
+{ $values { "m" sequence } }
{ $description "Adds the matrices component-wise." }
{ $examples
{ $example
} ;
HELP: m-
-{ $values { "m" sequence } { "m" sequence } { "m" sequence } }
+{ $values { "m" sequence } }
{ $description "Subtracts the matrices component-wise." }
{ $examples
{ $example
"T{ inet { host \"ftp.cdrom.com\" } { port 21 } }"
}
{ $example
- "USING: prettyprint urls ;"
+ "USING: io.sockets.secure prettyprint urls ;"
"URL\" https://google.com/\" url-addr ."
- "T{ secure"
- "{ addrspec T{ inet { host \"google.com\" } { port 443 } } }"
- "}"
+ "T{ secure\n { addrspec T{ inet { host \"google.com\" } { port 443 } } }\n}"
}
} ;
-USING: help.markup help.syntax strings ;
+USING: help.markup help.syntax literals sequences strings ;
IN: vocabs.files
HELP: vocab-tests-path
{ $description "Outputs a sequence of files comprising this vocabulary, or " { $link f } " if the vocabulary does not have a directory on disk." }
{ $examples
{ $example
- "USING: vocabs.files ; "
+ "USING: prettyprint vocabs.files ; "
"\"alien.libraries\" vocab-files ."
- "{"
- " \"resource:basis/alien/libraries/libraries.factor\""
- " \"resource:basis/alien/libraries/libraries-docs.factor\""
- " \"resource:basis/alien/libraries/libraries-tests.factor\""
- "}"
+ $[
+ {
+ "{"
+ " \"resource:basis/alien/libraries/libraries.factor\""
+ " \"resource:basis/alien/libraries/libraries-docs.factor\""
+ " \"resource:basis/alien/libraries/libraries-tests.factor\""
+ "}"
+ } "\n" join
+ ]
}
} ;
{ $description "Outputs a sequence of pathnames where the unit tests for " { $snippet "vocab" } " are located." }
{ $examples
{ $example
- "USING: vocabs.files ; "
+ "USING: prettyprint vocabs.files ; "
"\"xml\" vocab-tests ."
- "{"
- " \"resource:basis/xml/tests/xmode-dtd.factor\""
- " \"resource:basis/xml/tests/test.factor\""
- " \"resource:basis/xml/tests/state-parser-tests.factor\""
- " \"resource:basis/xml/tests/soap.factor\""
- " \"resource:basis/xml/tests/templating.factor\""
- " \"resource:basis/xml/tests/encodings.factor\""
- " \"resource:basis/xml/tests/xmltest.factor\""
- " \"resource:basis/xml/tests/funny-dtd.factor\""
- "}"
+ $[
+ {
+ "{"
+ " \"resource:basis/xml/tests/xmode-dtd.factor\""
+ " \"resource:basis/xml/tests/test.factor\""
+ " \"resource:basis/xml/tests/state-parser-tests.factor\""
+ " \"resource:basis/xml/tests/soap.factor\""
+ " \"resource:basis/xml/tests/templating.factor\""
+ " \"resource:basis/xml/tests/encodings.factor\""
+ " \"resource:basis/xml/tests/xmltest.factor\""
+ " \"resource:basis/xml/tests/funny-dtd.factor\""
+ " \"resource:basis/xml/tests/cdata.factor\""
+ "}"
+ } "\n" join
+ ]
}
} ;
{ $description "Opens the file at the given path using the given encoding, and returns a list of the lines in that file." }
{ $examples
{ $example
- "USING: io.files io.encodings.utf8 ;"
+ "USING: io.files io.encodings.utf8 prettyprint sequences ;"
"\"resource:core/kernel/kernel.factor\" utf8 file-lines first ."
- "! Copyright (C) 2004, 2009 Slava Pestov."
+ "\"! Copyright (C) 2004, 2009 Slava Pestov.\""
}
}
{ $errors "Throws an error if the file cannot be opened for reading." } ;
{ $description "Tests if " { $snippet "seq" } " starts with " { $snippet "begin" } ". If " { $snippet "begin" } " is longer than " { $snippet "seq" } ", this word outputs " { $link f } "." }
{ $examples
{ $example
- "root-cache get keys [ \"help.l\" head? ] filter ."
- "{ \"help.lint.checks\" \"help.lint.private\" \"help.lint\" }"
+ "USING: prettyprint sequences ;"
+ "{ \"accept\" \"adept\" \"advance\" \"advice\" \"affect\" } [ \"ad\" head? ] filter ."
+ "{ \"adept\" \"advance\" \"advice\" }"
}
} ;
{ { $slot "icon" } { "path to an icon image representing this error type." } }
{ { $slot "quot" } { "quotation that produces a list of all errors of this type." } }
{ { $slot "forget-quot" } { "a quotation that removes errors of this type for a given word." } }
- { { $slot "fatal?" } { "whether the error is fatal or not. default " { $snippet t } "." } }
+ { { $slot "fatal?" } { "whether the error is fatal or not. default " { $link t } "." } }
}
} ;
{ $description "Lists all errors in the system." } ;
HELP: error-file
+{ $values { "error" "an error" } { "file" "a file path" } }
{ $description "File in which the error occurred." } ;
HELP: <definition-error>
{ $values
{ "error" "an error." }
{ "definition" "an asset that contains the error." }
- { "class" "a tuple class deriving " { $snippet source-file-error } "." }
+ { "class" "a tuple class deriving source-file-error." }
+ { "source-file-error" source-file-error }
}
-{ $description "Creates a new " { $snippet source-file-error } " instance." } ;
+{ $description "Creates a new " { $link source-file-error } " instance." } ;
USING: definitions help.markup help.syntax kernel parser
-kernel.private vocabs classes quotations
+kernel.private vocabs classes quotations sequences
strings effects compiler.units ;
IN: words
{ $notes "Outputs " { $link f } " if the object is not a word." } ;
HELP: subwords
-{ $values { "word" word } }
+{ $values { "word" word } { "seq" sequence } }
{ $description "Lists all specializations for the given word." }
{ $examples
{ $example
- "USING: math.functions ;"
- "clear \ sin subwords ."
- "{ M\ object sin M\ complex sin M\ real sin M\ float sin }"
+ "USING: math.functions prettyprint words ;"
+ "\\ sin subwords ."
+ "{ M\\ object sin M\\ complex sin M\\ real sin M\\ float sin }"
}
}
{ $notes "Outputs " { $link f } " if the word isn't generic." } ;