2012-09-11 17:46:20 -07:00
|
|
|
extern mod std;
|
2011-12-15 16:10:01 -08:00
|
|
|
|
2012-09-05 12:32:05 -07:00
|
|
|
use comm::Chan;
|
|
|
|
use comm::send;
|
2011-12-15 16:10:01 -08:00
|
|
|
|
|
|
|
fn main() { test05(); }
|
|
|
|
|
2012-01-11 09:58:05 -08:00
|
|
|
fn test05_start(&&f: fn~(int)) {
|
2011-12-15 16:10:01 -08:00
|
|
|
f(22);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test05() {
|
|
|
|
let three = ~3;
|
2012-01-11 09:58:05 -08:00
|
|
|
let fn_to_send = fn~(n: int) {
|
2011-12-22 17:53:53 -08:00
|
|
|
log(error, *three + n); // will copy x into the closure
|
2011-12-15 16:10:01 -08:00
|
|
|
assert(*three == 3);
|
|
|
|
};
|
2012-06-14 19:02:30 -07:00
|
|
|
task::spawn(fn~(move fn_to_send) {
|
2012-01-04 21:14:53 -08:00
|
|
|
test05_start(fn_to_send);
|
|
|
|
});
|
2011-12-15 16:10:01 -08:00
|
|
|
}
|