@@ -1671,6 +1671,10 @@ vec_elems : [expr [',' expr]*] | [expr ',' ".." expr]
16711671A [ _ vector_ ] ( #vector-types ) _ expression_ is written by enclosing zero or
16721672more comma-separated expressions of uniform type in square brackets.
16731673
1674+ In the ` [expr ',' ".." expr] ` form, the expression after the ` ".." `
1675+ must be a constant expression that can be evaluated at compile time, such
1676+ as a [ literal] ( #literals ) or a [ static item] ( #static-items ) .
1677+
16741678~~~~
16751679[1, 2, 3, 4];
16761680["a", "b", "c", "d"];
@@ -2156,6 +2160,19 @@ do f |j| {
21562160}
21572161~~~~
21582162
2163+ In this example, both calls to the (binary) function ` k ` are equivalent:
2164+
2165+ ~~~~
2166+ # fn k(x:int, f: &fn(int)) { }
2167+ # fn l(i: int) { }
2168+
2169+ k(3, |j| l(j));
2170+
2171+ do k(3) |j| {
2172+ l(j);
2173+ }
2174+ ~~~~
2175+
21592176
21602177### For expressions
21612178
@@ -2184,7 +2201,7 @@ and early boolean-valued returns from the `block` function,
21842201such that the meaning of ` break ` and ` loop ` is preserved in a primitive loop
21852202when rewritten as a ` for ` loop controlled by a higher order function.
21862203
2187- An example a for loop:
2204+ An example of a for loop over the contents of a vector :
21882205
21892206~~~~
21902207# type foo = int;
@@ -2198,6 +2215,14 @@ for v.each |e| {
21982215}
21992216~~~~
22002217
2218+ An example of a for loop over a series of integers:
2219+
2220+ ~~~~
2221+ # fn bar(b:uint) { }
2222+ for uint::range(0, 256) |i| {
2223+ bar(i);
2224+ }
2225+ ~~~~
22012226
22022227### If expressions
22032228
@@ -2474,6 +2499,7 @@ fail_unless!(b != "world");
24742499
24752500The vector type constructor represents a homogeneous array of values of a given type.
24762501A vector has a fixed size.
2502+ (Operations like ` vec::push ` operate solely on owned vectors.)
24772503A vector type can be annotated with a _ definite_ size,
24782504written with a trailing asterisk and integer literal, such as ` [int * 10] ` .
24792505Such a definite-sized vector type is a first-class type, since its size is known statically.
@@ -2484,6 +2510,10 @@ such as `&[T]`, `@[T]` or `~[T]`.
24842510The kind of a vector type depends on the kind of its element type,
24852511as with other simple structural types.
24862512
2513+ Expressions producing vectors of definite size cannot be evaluated in a
2514+ context expecting a vector of indefinite size; one must copy the
2515+ definite-sized vector contents into a distinct vector of indefinite size.
2516+
24872517An example of a vector type and its use:
24882518
24892519~~~~
0 commit comments