Skip to content

Commit 8c47b0c

Browse files
committed
---
yaml --- r: 148668 b: refs/heads/try2 c: 9896beb h: refs/heads/master v: v3
1 parent 9751617 commit 8c47b0c

File tree

190 files changed

+1584
-926
lines changed

Some content is hidden

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

190 files changed

+1584
-926
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: e1580f6d09f0cd990c3eed55b1d6181af3258791
8+
refs/heads/try2: 9896beb5b5363eae1f8bfee35c12b3d78185e0e6
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: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,8 @@ src/.DS_Store
7474
/doc/html
7575
/doc/latex
7676
/doc/std
77-
/doc/arena
7877
/doc/extra
7978
/doc/flate
80-
/doc/glob
8179
/doc/green
8280
/doc/native
8381
/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 CFG_DISABLE_RPATH
127+
ifdef DISABLE_RPATH
128128
# NOTE: make this CFG_RUSTC_FLAGS after stage0 snapshot
129129
RUSTFLAGS_STAGE1 += --no-rpath
130130
RUSTFLAGS_STAGE2 += --no-rpath

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 = task::try(proc() {
264+
let result = do task::try {
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-
spawn(proc() {
224+
do spawn {
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-
spawn(proc() {
241+
do spawn {
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-
green::start(argc, argv, proc() {
239+
do green::start(argc, argv) {
240240
main();
241-
})
241+
}
242242
}
243243
244244
fn main() {}

branches/try2/doc/guide-tasks.md

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ 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+
}
8085
~~~~
8186

8287
In Rust, there is nothing special about creating tasks: a task is not a
@@ -98,10 +103,10 @@ an environment that it carries across tasks.
98103
// Generate some state locally
99104
let child_task_number = generate_task_number();
100105
101-
spawn(proc() {
106+
do spawn {
102107
// Capture it in the remote task
103108
println!("I am child number {}", child_task_number);
104-
});
109+
}
105110
~~~
106111

107112
## Communication
@@ -127,10 +132,10 @@ concurrently:
127132
128133
let (port, chan): (Port<int>, Chan<int>) = Chan::new();
129134
130-
spawn(proc() {
135+
do spawn || {
131136
let result = some_expensive_computation();
132137
chan.send(result);
133-
});
138+
}
134139
135140
some_other_expensive_computation();
136141
let result = port.recv();
@@ -155,10 +160,10 @@ spawns the child task.
155160
# use std::task::spawn;
156161
# fn some_expensive_computation() -> int { 42 }
157162
# let (port, chan) = Chan::new();
158-
spawn(proc() {
163+
do spawn || {
159164
let result = some_expensive_computation();
160165
chan.send(result);
161-
});
166+
}
162167
~~~~
163168

164169
Notice that the creation of the task closure transfers `chan` to the child
@@ -190,15 +195,15 @@ of tasks? The following program is ill-typed:
190195
# fn some_expensive_computation() -> int { 42 }
191196
let (port, chan) = Chan::new();
192197
193-
spawn(proc() {
198+
do spawn {
194199
chan.send(some_expensive_computation());
195-
});
200+
}
196201
197202
// ERROR! The previous spawn statement already owns the channel,
198203
// so the compiler will not allow it to be captured again
199-
spawn(proc() {
204+
do spawn {
200205
chan.send(some_expensive_computation());
201-
});
206+
}
202207
~~~
203208

204209
Instead we can use a `SharedChan`, a type that allows a single
@@ -212,9 +217,9 @@ let (port, chan) = SharedChan::new();
212217
for init_val in range(0u, 3) {
213218
// Create a new channel handle to distribute to the child task
214219
let child_chan = chan.clone();
215-
spawn(proc() {
220+
do spawn {
216221
child_chan.send(some_expensive_computation(init_val));
217-
});
222+
}
218223
}
219224
220225
let result = port.recv() + port.recv() + port.recv();
@@ -242,9 +247,9 @@ might look like the example below.
242247
// Create a vector of ports, one for each child task
243248
let ports = vec::from_fn(3, |init_val| {
244249
let (port, chan) = Chan::new();
245-
spawn(proc() {
250+
do spawn {
246251
chan.send(some_expensive_computation(init_val));
247-
});
252+
}
248253
port
249254
});
250255
@@ -291,7 +296,7 @@ fn partial_sum(start: uint) -> f64 {
291296
}
292297
293298
fn main() {
294-
let mut futures = vec::from_fn(1000, |ind| extra::future::Future::spawn( proc() { partial_sum(ind) }));
299+
let mut futures = vec::from_fn(1000, |ind| do extra::future::Future::spawn { partial_sum(ind) });
295300
296301
let mut final_res = 0f64;
297302
for ft in futures.mut_iter() {
@@ -334,11 +339,11 @@ fn main() {
334339
let (port, chan) = Chan::new();
335340
chan.send(numbers_arc.clone());
336341
337-
spawn(proc() {
342+
do spawn {
338343
let local_arc : Arc<~[f64]> = port.recv();
339344
let task_numbers = local_arc.get();
340345
println!("{}-norm = {}", num, pnorm(task_numbers, num));
341-
});
346+
}
342347
}
343348
}
344349
~~~
@@ -412,13 +417,13 @@ termination with an error).
412417
# use std::task;
413418
# fn some_condition() -> bool { false }
414419
# fn calculate_result() -> int { 0 }
415-
let result: Result<int, ()> = task::try(proc() {
420+
let result: Result<int, ()> = do task::try {
416421
if some_condition() {
417422
calculate_result()
418423
} else {
419424
fail!("oops!");
420425
}
421-
});
426+
};
422427
assert!(result.is_err());
423428
~~~
424429

@@ -497,9 +502,9 @@ Here is the code for the parent task:
497502
498503
let (from_child, to_child) = DuplexStream::new();
499504
500-
spawn(proc() {
505+
do spawn {
501506
stringifier(&to_child);
502-
});
507+
};
503508
504509
from_child.send(22);
505510
assert!(from_child.recv() == ~"22");

branches/try2/doc/index.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ 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)
4140
* [The `flate` compression library](flate/index.html)
42-
* [The `glob` file path matching library](glob/index.html)
4341

4442
# Tooling
4543

branches/try2/doc/rust.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,6 +2751,52 @@ 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+
27542800
### For expressions
27552801

27562802
~~~~ {.ebnf .gram}

branches/try2/doc/tutorial.md

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,20 +1796,48 @@ call_it(proc(n) {
17961796
});
17971797
~~~~
17981798
1799-
A practical example of this pattern is found when using the `spawn` function,
1800-
which starts a new task.
1799+
This is such a useful pattern that Rust has a special form of function
1800+
call for these functions.
1801+
1802+
~~~~
1803+
# fn call_it(op: proc(v: int)) { }
1804+
do call_it() |n| {
1805+
println!("{}", n);
1806+
}
1807+
~~~~
1808+
1809+
The call is prefixed with the keyword `do` and, instead of writing the
1810+
final procedure inside the argument list, it appears outside of the
1811+
parentheses, where it looks more like a typical block of
1812+
code.
1813+
1814+
`do` is a convenient way to create tasks with the `task::spawn`
1815+
function. `spawn` has the signature `spawn(fn: proc())`. In other
1816+
words, it is a function that takes an owned closure that takes no
1817+
arguments.
18011818
18021819
~~~~
18031820
use std::task::spawn;
1804-
spawn(proc() {
1805-
debug!("I'm a new task")
1806-
});
1821+
1822+
do spawn() || {
1823+
debug!("I'm a task, whatever");
1824+
}
1825+
~~~~
1826+
1827+
Look at all those bars and parentheses -- that's two empty argument
1828+
lists back to back. Since that is so unsightly, empty argument lists
1829+
may be omitted from `do` expressions.
1830+
1831+
~~~~
1832+
use std::task::spawn;
1833+
1834+
do spawn {
1835+
debug!("Kablam!");
1836+
}
18071837
~~~~
18081838
1809-
If you want to see the output of `debug!` statements, you will need to turn on
1810-
`debug!` logging. To enable `debug!` logging, set the RUST_LOG environment
1811-
variable to the name of your crate, which, for a file named `foo.rs`, will be
1812-
`foo` (e.g., with bash, `export RUST_LOG=foo`).
1839+
If you want to see the output of `debug!` statements, you will need to turn on `debug!` logging.
1840+
To enable `debug!` logging, set the RUST_LOG environment variable to the name of your crate, which, for a file named `foo.rs`, will be `foo` (e.g., with bash, `export RUST_LOG=foo`).
18131841
18141842
# Methods
18151843

branches/try2/mk/crates.mk

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
# automatically generated for all stage/host/target combinations.
5050
################################################################################
5151

52-
TARGET_CRATES := std extra green rustuv native flate arena glob
52+
TARGET_CRATES := std extra green rustuv native flate
5353
HOST_CRATES := syntax rustc rustdoc rustpkg
5454
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
5555
TOOLS := compiletest rustpkg rustdoc rustc
@@ -60,12 +60,10 @@ DEPS_green := std
6060
DEPS_rustuv := std native:uv native:uv_support
6161
DEPS_native := std
6262
DEPS_syntax := std extra
63-
DEPS_rustc := syntax native:rustllvm flate arena
63+
DEPS_rustc := syntax native:rustllvm flate
6464
DEPS_rustdoc := rustc native:sundown
6565
DEPS_rustpkg := rustc
6666
DEPS_flate := std native:miniz
67-
DEPS_arena := std extra
68-
DEPS_glob := std
6967

7068
TOOL_DEPS_compiletest := extra green rustuv
7169
TOOL_DEPS_rustpkg := rustpkg green rustuv

0 commit comments

Comments
 (0)