]> gitweb.factorcode.org Git - factor.git/blob - basis/specialized-vectors/specialized-vectors-docs.factor
Specialized array overhaul
[factor.git] / basis / specialized-vectors / specialized-vectors-docs.factor
1 USING: help.markup help.syntax byte-vectors alien byte-arrays ;
2 IN: specialized-vectors
3
4 HELP: SPECIALIZED-VECTOR:
5 { $syntax "SPECIALIZED-VECTOR: type" }
6 { $values { "type" "a C type" } }
7 { $description "Brings a specialized vector for holding values of " { $snippet "type" } " into the vocabulary search path. The generated words are documented in " { $link "specialized-vector-words" } "." } ;
8
9 ARTICLE: "specialized-vector-words" "Specialized vector words"
10 "The " { $link POSTPONE: SPECIALIZED-VECTOR: } " parsing word generates the specialized vector type if it hasn't been generated already, and adds the following words to the vocabulary search path, where " { $snippet "T" } " is the C type in question:"
11 { $table
12     { { $snippet "T-vector" } { "The class of vectors with elements of type " { $snippet "T" } } }
13     { { $snippet "<T-vector>" } { "Constructor for vectors with elements of type " { $snippet "T" } "; stack effect " { $snippet "( len -- vector )" } } }
14     { { $snippet ">T-vector" } { "Converts a sequence into a specialized vector of type " { $snippet "T" } "; stack effect " { $snippet "( seq -- vector )" } } }
15     { { $snippet "T-vector{" } { "Literal syntax, consists of a series of values terminated by " { $snippet "}" } } }
16 }
17 "Behind the scenes, these words are placed in a vocabulary named " { $snippet "specialized-vectors.instances.T" } ", however this vocabulary should not be placed in a " { $link POSTPONE: USING: } " form directly. Instead, always use " { $link POSTPONE: SPECIALIZED-VECTOR: } ". This ensures that the vocabulary can get generated the first time it is needed." ;
18
19 ARTICLE: "specialized-vector-c" "Passing specialized arrays to C functions"
20 "Each specialized array has a " { $slot "underlying" } " slot holding a specialized array, which in turn has an " { $slot "underlying" } " slot holding a " { $link byte-array } " with the raw data. Passing a specialized vector as a parameter to a C function call will automatically extract the underlying data. To get at the underlying data directly, call the " { $link >c-ptr } " word on a specialized vector." ;
21
22 ARTICLE: "specialized-vectors" "Specialized vectors"
23 "The " { $vocab-link "specialized-vectors" } " vocabulary implements resizable sequence types for storing machine values in a space-efficient manner without boxing."
24 { $subsection "specialized-vector-words" }
25 { $subsection "specialized-vector-c" }
26 "The " { $vocab-link "specialized-arrays" } " vocabulary provides a fixed-length version of this abstraction." ;
27
28 ABOUT: "specialized-vectors"