Skip to content

Commit 9f7f483

Browse files
committed
---
yaml --- r: 148726 b: refs/heads/try2 c: 5a61812 h: refs/heads/master v: v3
1 parent 71b8922 commit 9f7f483

File tree

288 files changed

+2298
-2067
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

288 files changed

+2298
-2067
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 9b1865a7faafe16af9eb9f804e82065b5a6f1e24
8+
refs/heads/try2: 5a618129b842f875dac5531ce7b8385fe4fcda6c
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ src/.DS_Store
7474
/doc/html
7575
/doc/latex
7676
/doc/std
77+
/doc/arena
7778
/doc/extra
7879
/doc/flate
80+
/doc/glob
7981
/doc/green
8082
/doc/native
8183
/doc/rustc

branches/try2/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ endif
124124
ifdef TRACE
125125
CFG_RUSTC_FLAGS += -Z trace
126126
endif
127-
ifdef DISABLE_RPATH
127+
ifdef CFG_DISABLE_RPATH
128128
# NOTE: make this CFG_RUSTC_FLAGS after stage0 snapshot
129129
RUSTFLAGS_STAGE1 += --no-rpath
130130
RUSTFLAGS_STAGE2 += --no-rpath

branches/try2/configure

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,10 @@ do
916916
LLVM_OPTS="$LLVM_OPTS --disable-terminfo"
917917
# Try to have LLVM pull in as few dependencies as possible (#9397)
918918
LLVM_OPTS="$LLVM_OPTS --disable-zlib --disable-libffi"
919+
# LLVM says it needs a "new" clang/gcc, but we seem to get by ok with
920+
# older versions on the bots. Get by for a little longer by asking it to
921+
# not do version detection
922+
LLVM_OPTS="$LLVM_OPTS --disable-compiler-version-checks"
919923

920924
# Use win32 native thread/lock apis instead of pthread wrapper.
921925
# (llvm's configure tries to find pthread first, so we have to disable it explicitly.)

branches/try2/doc/guide-conditions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,15 +261,15 @@ use std::task;
261261
fn main() {
262262
263263
// Isolate failure within a subtask.
264-
let result = do task::try {
264+
let result = task::try(proc() {
265265
266266
// The protected logic.
267267
let pairs = read_int_pairs();
268268
for &(a,b) in pairs.iter() {
269269
println!("{:4.4d}, {:4.4d}", a, b);
270270
}
271271
272-
};
272+
});
273273
if result.is_err() {
274274
println!("parsing failed");
275275
}

branches/try2/doc/guide-pointers.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ struct Point {
221221

222222
fn main() {
223223
let a = Point { x: 10, y: 20 };
224-
do spawn {
224+
spawn(proc() {
225225
println!("{}", a.x);
226-
}
226+
});
227227
}
228228
~~~
229229

@@ -238,9 +238,9 @@ struct Point {
238238

239239
fn main() {
240240
let a = ~Point { x: 10, y: 20 };
241-
do spawn {
241+
spawn(proc() {
242242
println!("{}", a.x);
243-
}
243+
});
244244
}
245245
~~~
246246

branches/try2/doc/guide-runtime.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@ extern mod green;
236236
237237
#[start]
238238
fn start(argc: int, argv: **u8) -> int {
239-
do green::start(argc, argv) {
239+
green::start(argc, argv, proc() {
240240
main();
241-
}
241+
})
242242
}
243243
244244
fn main() {}

branches/try2/doc/guide-tasks.md

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ spawn(print_message);
7777
7878
// Print something more profound in a different task using a lambda expression
7979
spawn(proc() println!("I am also running in a different task!") );
80-
81-
// The canonical way to spawn is using `do` notation
82-
do spawn {
83-
println!("I too am running in a different task!");
84-
}
8580
~~~~
8681

8782
In Rust, there is nothing special about creating tasks: a task is not a
@@ -103,10 +98,10 @@ an environment that it carries across tasks.
10398
// Generate some state locally
10499
let child_task_number = generate_task_number();
105100
106-
do spawn {
101+
spawn(proc() {
107102
// Capture it in the remote task
108103
println!("I am child number {}", child_task_number);
109-
}
104+
});
110105
~~~
111106

112107
## Communication
@@ -132,10 +127,10 @@ concurrently:
132127
133128
let (port, chan): (Port<int>, Chan<int>) = Chan::new();
134129
135-
do spawn || {
130+
spawn(proc() {
136131
let result = some_expensive_computation();
137132
chan.send(result);
138-
}
133+
});
139134
140135
some_other_expensive_computation();
141136
let result = port.recv();
@@ -160,10 +155,10 @@ spawns the child task.
160155
# use std::task::spawn;
161156
# fn some_expensive_computation() -> int { 42 }
162157
# let (port, chan) = Chan::new();
163-
do spawn || {
158+
spawn(proc() {
164159
let result = some_expensive_computation();
165160
chan.send(result);
166-
}
161+
});
167162
~~~~
168163

169164
Notice that the creation of the task closure transfers `chan` to the child
@@ -195,15 +190,15 @@ of tasks? The following program is ill-typed:
195190
# fn some_expensive_computation() -> int { 42 }
196191
let (port, chan) = Chan::new();
197192
198-
do spawn {
193+
spawn(proc() {
199194
chan.send(some_expensive_computation());
200-
}
195+
});
201196
202197
// ERROR! The previous spawn statement already owns the channel,
203198
// so the compiler will not allow it to be captured again
204-
do spawn {
199+
spawn(proc() {
205200
chan.send(some_expensive_computation());
206-
}
201+
});
207202
~~~
208203

209204
Instead we can use a `SharedChan`, a type that allows a single
@@ -217,9 +212,9 @@ let (port, chan) = SharedChan::new();
217212
for init_val in range(0u, 3) {
218213
// Create a new channel handle to distribute to the child task
219214
let child_chan = chan.clone();
220-
do spawn {
215+
spawn(proc() {
221216
child_chan.send(some_expensive_computation(init_val));
222-
}
217+
});
223218
}
224219
225220
let result = port.recv() + port.recv() + port.recv();
@@ -247,9 +242,9 @@ might look like the example below.
247242
// Create a vector of ports, one for each child task
248243
let ports = vec::from_fn(3, |init_val| {
249244
let (port, chan) = Chan::new();
250-
do spawn {
245+
spawn(proc() {
251246
chan.send(some_expensive_computation(init_val));
252-
}
247+
});
253248
port
254249
});
255250
@@ -296,7 +291,7 @@ fn partial_sum(start: uint) -> f64 {
296291
}
297292
298293
fn main() {
299-
let mut futures = vec::from_fn(1000, |ind| do extra::future::Future::spawn { partial_sum(ind) });
294+
let mut futures = vec::from_fn(1000, |ind| extra::future::Future::spawn( proc() { partial_sum(ind) }));
300295
301296
let mut final_res = 0f64;
302297
for ft in futures.mut_iter() {
@@ -339,11 +334,11 @@ fn main() {
339334
let (port, chan) = Chan::new();
340335
chan.send(numbers_arc.clone());
341336
342-
do spawn {
337+
spawn(proc() {
343338
let local_arc : Arc<~[f64]> = port.recv();
344339
let task_numbers = local_arc.get();
345340
println!("{}-norm = {}", num, pnorm(task_numbers, num));
346-
}
341+
});
347342
}
348343
}
349344
~~~
@@ -417,13 +412,13 @@ termination with an error).
417412
# use std::task;
418413
# fn some_condition() -> bool { false }
419414
# fn calculate_result() -> int { 0 }
420-
let result: Result<int, ()> = do task::try {
415+
let result: Result<int, ()> = task::try(proc() {
421416
if some_condition() {
422417
calculate_result()
423418
} else {
424419
fail!("oops!");
425420
}
426-
};
421+
});
427422
assert!(result.is_err());
428423
~~~
429424

@@ -502,9 +497,9 @@ Here is the code for the parent task:
502497
503498
let (from_child, to_child) = DuplexStream::new();
504499
505-
do spawn {
500+
spawn(proc() {
506501
stringifier(&to_child);
507-
};
502+
});
508503
509504
from_child.send(22);
510505
assert!(from_child.recv() == ~"22");

branches/try2/doc/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ li {list-style-type: none; }
3737
* [The Rust parser, `libsyntax`](syntax/index.html)
3838
* [The Rust compiler, `librustc`](rustc/index.html)
3939

40+
* [The `arena` allocation library](arena/index.html)
4041
* [The `flate` compression library](flate/index.html)
42+
* [The `glob` file path matching library](glob/index.html)
4143

4244
# Tooling
4345

branches/try2/doc/rust.md

Lines changed: 38 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,52 +2751,6 @@ but must enclose it.
27512751

27522752
A `loop` expression is only permitted in the body of a loop.
27532753

2754-
### Do expressions
2755-
2756-
~~~~ {.ebnf .gram}
2757-
do_expr : "do" expr [ '|' ident_list '|' ] ? '{' block '}' ;
2758-
~~~~
2759-
2760-
A _do expression_ provides a more-familiar block syntax
2761-
for invoking a function and passing it a newly-created a procedure.
2762-
2763-
The optional `ident_list` and `block` provided in a `do` expression are parsed
2764-
as though they constitute a procedure expression;
2765-
if the `ident_list` is missing, an empty `ident_list` is implied.
2766-
2767-
The procedure expression is then provided as a _trailing argument_
2768-
to the outermost [call](#call-expressions) or
2769-
[method call](#method-call-expressions) expression
2770-
in the `expr` following `do`.
2771-
If the `expr` is a [path expression](#path-expressions), it is parsed as though it is a call expression.
2772-
If the `expr` is a [field expression](#field-expressions), it is parsed as though it is a method call expression.
2773-
2774-
In this example, both calls to `f` are equivalent:
2775-
2776-
~~~~
2777-
# fn f(f: proc(int)) { }
2778-
# fn g(i: int) { }
2779-
2780-
f(proc(j) { g(j) });
2781-
2782-
do f |j| {
2783-
g(j);
2784-
}
2785-
~~~~
2786-
2787-
In this example, both calls to the (binary) function `k` are equivalent:
2788-
2789-
~~~~
2790-
# fn k(x:int, f: proc(int)) { }
2791-
# fn l(i: int) { }
2792-
2793-
k(3, proc(j) { l(j) });
2794-
2795-
do k(3) |j| {
2796-
l(j);
2797-
}
2798-
~~~~
2799-
28002754
### For expressions
28012755

28022756
~~~~ {.ebnf .gram}
@@ -2864,14 +2818,15 @@ match_pat : pat [ ".." pat ] ? [ "if" expr ] ;
28642818

28652819
A `match` expression branches on a *pattern*. The exact form of matching that
28662820
occurs depends on the pattern. Patterns consist of some combination of
2867-
literals, destructured enum constructors, structures, records and tuples, variable binding
2868-
specifications, wildcards (`..`), and placeholders (`_`). A `match` expression has a *head
2869-
expression*, which is the value to compare to the patterns. The type of the
2870-
patterns must equal the type of the head expression.
2821+
literals, destructured vectors or enum constructors, structures, records and
2822+
tuples, variable binding specifications, wildcards (`..`), and placeholders
2823+
(`_`). A `match` expression has a *head expression*, which is the value to
2824+
compare to the patterns. The type of the patterns must equal the type of the
2825+
head expression.
28712826

2872-
In a pattern whose head expression has an `enum` type, a placeholder (`_`) stands for a
2873-
*single* data field, whereas a wildcard `..` stands for *all* the fields of a particular
2874-
variant. For example:
2827+
In a pattern whose head expression has an `enum` type, a placeholder (`_`)
2828+
stands for a *single* data field, whereas a wildcard `..` stands for *all* the
2829+
fields of a particular variant. For example:
28752830

28762831
~~~~
28772832
enum List<X> { Nil, Cons(X, ~List<X>) }
@@ -2885,11 +2840,35 @@ match x {
28852840
}
28862841
~~~~
28872842

2888-
The first pattern matches lists constructed by applying `Cons` to any head value, and a
2889-
tail value of `~Nil`. The second pattern matches _any_ list constructed with `Cons`,
2890-
ignoring the values of its arguments. The difference between `_` and `..` is that the pattern
2891-
`C(_)` is only type-correct if `C` has exactly one argument, while the pattern `C(..)` is
2892-
type-correct for any enum variant `C`, regardless of how many arguments `C` has.
2843+
The first pattern matches lists constructed by applying `Cons` to any head
2844+
value, and a tail value of `~Nil`. The second pattern matches _any_ list
2845+
constructed with `Cons`, ignoring the values of its arguments. The difference
2846+
between `_` and `..` is that the pattern `C(_)` is only type-correct if `C` has
2847+
exactly one argument, while the pattern `C(..)` is type-correct for any enum
2848+
variant `C`, regardless of how many arguments `C` has.
2849+
2850+
Used inside a vector pattern, `..` stands for any number of elements. This
2851+
wildcard can be used at most once for a given vector, which implies that it
2852+
cannot be used to specifically match elements that are at an unknown distance
2853+
from both ends of a vector, like `[.., 42, ..]`. If followed by a variable name,
2854+
it will bind the corresponding slice to the variable. Example:
2855+
2856+
~~~~
2857+
fn is_symmetric(list: &[uint]) -> bool {
2858+
match list {
2859+
[] | [_] => true,
2860+
[x, ..inside, y] if x == y => is_symmetric(inside),
2861+
_ => false
2862+
}
2863+
}
2864+
2865+
fn main() {
2866+
let sym = &[0, 1, 4, 2, 4, 1, 0];
2867+
let not_sym = &[0, 1, 7, 2, 4, 1, 0];
2868+
assert!(is_symmetric(sym));
2869+
assert!(!is_symmetric(not_sym));
2870+
}
2871+
~~~~
28932872

28942873
A `match` behaves differently depending on whether or not the head expression
28952874
is an [lvalue or an rvalue](#lvalues-rvalues-and-temporaries).
@@ -2972,7 +2951,7 @@ let z = match x { &0 => "zero", _ => "some" };
29722951
assert_eq!(y, z);
29732952
~~~~
29742953

2975-
A pattern that's just an identifier, like `Nil` in the previous answer,
2954+
A pattern that's just an identifier, like `Nil` in the previous example,
29762955
could either refer to an enum variant that's in scope, or bind a new variable.
29772956
The compiler resolves this ambiguity by forbidding variable bindings that occur
29782957
in `match` patterns from shadowing names of variants that are in scope.

0 commit comments

Comments
 (0)