2011-12-15 18:10:01 -06:00
|
|
|
use std;
|
|
|
|
|
2012-01-09 07:53:13 -06:00
|
|
|
import comm::chan;
|
|
|
|
import comm::send;
|
2011-12-15 18:10:01 -06:00
|
|
|
|
|
|
|
fn main() { test05(); }
|
|
|
|
|
2012-01-11 11:58:05 -06:00
|
|
|
fn test05_start(&&f: fn~(int)) {
|
2011-12-15 18:10:01 -06:00
|
|
|
f(22);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test05() {
|
|
|
|
let three = ~3;
|
2012-01-11 11:58:05 -06:00
|
|
|
let fn_to_send = fn~(n: int) {
|
2011-12-22 19:53:53 -06:00
|
|
|
log(error, *three + n); // will copy x into the closure
|
2011-12-15 18:10:01 -06:00
|
|
|
assert(*three == 3);
|
|
|
|
};
|
2012-01-11 11:58:05 -06:00
|
|
|
task::spawn(fn~[move fn_to_send]() {
|
2012-01-04 23:14:53 -06:00
|
|
|
test05_start(fn_to_send);
|
|
|
|
});
|
2011-12-15 18:10:01 -06:00
|
|
|
}
|