@@ -2478,13 +2478,16 @@ type `float` may not be equal to the largest *supported* floating-point type.
24782478
24792479### Textual types
24802480
2481- The types ` char ` and ` ~ str` hold textual data.
2481+ The types ` char ` and ` str ` hold textual data.
24822482
24832483A value of type ` char ` is a Unicode character, represented as a 32-bit
24842484unsigned word holding a UCS-4 codepoint.
24852485
2486- A value of type ` ~ str` is a Unicode string, represented as a vector of 8-bit
2486+ A value of type ` str ` is a Unicode string, represented as a vector of 8-bit
24872487unsigned bytes holding a sequence of UTF-8 codepoints.
2488+ Since ` str ` is of indefinite size, it is not a _ first class_ type,
2489+ but can only be instantiated through a pointer type,
2490+ such as ` &str ` , ` @str ` or ` ~str ` .
24882491
24892492
24902493### Tuple types
@@ -2505,45 +2508,35 @@ order specified by the tuple type.
25052508An example of a tuple type and its use:
25062509
25072510~~~~
2508- type pair = (int,~ str);
2509- let p: pair = (10,~ "hello");
2511+ type Pair = (int,& str);
2512+ let p: Pair = (10,"hello");
25102513let (a, b) = p;
2511- assert b != ~ "world";
2514+ assert b != "world";
25122515~~~~
25132516
25142517
25152518### Vector types
25162519
2517- The vector type-constructor represents a homogeneous array of values of a
2518- given type. A vector has a fixed size. The kind of a vector type depends on
2519- the kind of its member type, as with other simple structural types.
2520+ The vector type-constructor represents a homogeneous array of values of a given type.
2521+ A vector has a fixed size.
2522+ A vector type can be accompanied by _ definite_ size, written with a trailing asterisk and integer literal, such as ` [int * 10] ` .
2523+ Such a definite-sized vector can be treated as a first class type since its size is known statically.
2524+ A vector without such a size is said to be of _ indefinite_ size,
2525+ and is therefore not a _ first class_ type,
2526+ can only be instantiated through a pointer type,
2527+ such as ` &[T] ` , ` @[T] ` or ` ~[T] ` .
2528+ The kind of a vector type depends on the kind of its member type, as with other simple structural types.
25202529
25212530An example of a vector type and its use:
25222531
25232532~~~~
2524- let v: ~ [int] = ~ [7, 5, 3];
2533+ let v: & [int] = [7, 5, 3];
25252534let i: int = v[2];
25262535assert (i == 3);
25272536~~~~
25282537
2529- Vectors always * allocate* a storage region sufficient to store the first power
2530- of two worth of elements greater than or equal to the size of the vector. This
2531- behaviour supports idiomatic in-place "growth" of a mutable slot holding a
2532- vector:
2533-
2534-
2535- ~~~~
2536- let mut v: ~[int] = ~[1, 2, 3];
2537- v += ~[4, 5, 6];
2538- ~~~~
2539-
2540- Normal vector concatenation causes the allocation of a fresh vector to hold
2541- the result; in this case, however, the slot holding the vector recycles the
2542- underlying storage in-place (since the reference-count of the underlying
2543- storage is equal to 1).
2544-
2545- All accessible elements of a vector are always initialized, and access to a
2546- vector is always bounds-checked.
2538+ All accessible elements of a vector are always initialized, and access to a vector is always bounds-checked.
2539+ In the case of a definite-
25472540
25482541
25492542### Structure types
0 commit comments