2011-12-15 18:10:01 -06:00
|
|
|
use std;
|
|
|
|
|
|
|
|
import std::comm;
|
|
|
|
import std::comm::chan;
|
|
|
|
import std::comm::send;
|
|
|
|
|
|
|
|
fn main() { test05(); }
|
|
|
|
|
|
|
|
fn test05_start(&&f: sendfn(int)) {
|
|
|
|
f(22);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test05() {
|
|
|
|
let three = ~3;
|
|
|
|
let fn_to_send = sendfn(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);
|
|
|
|
};
|
|
|
|
task::spawn(fn_to_send, test05_start);
|
|
|
|
}
|