Change the syntax for RECV from "var <- port" to "port |> var".
This commit is contained in:
parent
2119e3b5b9
commit
a7a42c24be
@ -1256,11 +1256,11 @@ fn parse_assign_expr(&parser p) -> @ast::expr {
|
||||
ret @spanned(lo, rhs.span.hi,
|
||||
ast::expr_send(lhs, rhs, p.get_ann()));
|
||||
}
|
||||
case (token::LARROW) {
|
||||
case (token::RECV) {
|
||||
p.bump();
|
||||
auto rhs = parse_expr(p);
|
||||
ret @spanned(lo, rhs.span.hi,
|
||||
ast::expr_recv(lhs, rhs, p.get_ann()));
|
||||
ast::expr_recv(rhs, lhs, p.get_ann()));
|
||||
}
|
||||
case (_) { /* fall through */ }
|
||||
}
|
||||
|
@ -617,10 +617,10 @@ fn print_expr(ps s, &@ast::expr expr) {
|
||||
print_expr(s, rhs);
|
||||
}
|
||||
case (ast::expr_recv(?lhs, ?rhs, _)) {
|
||||
print_expr(s, lhs);
|
||||
space(s.s);
|
||||
wrd1(s, "<-");
|
||||
print_expr(s, rhs);
|
||||
space(s.s);
|
||||
wrd1(s, "|>");
|
||||
print_expr(s, lhs);
|
||||
}
|
||||
case (ast::expr_field(?expr,?id,_)) {
|
||||
print_expr(s, expr);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// error-pattern: mismatched types
|
||||
|
||||
fn main() {
|
||||
10 <- 10;
|
||||
10 |> 10;
|
||||
}
|
@ -13,5 +13,5 @@ fn main() {
|
||||
let port[int] p = port();
|
||||
spawn child();
|
||||
let int x;
|
||||
x <- p;
|
||||
p |> x;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ io fn main() {
|
||||
let int value = 0;
|
||||
while (i > 0) {
|
||||
log i;
|
||||
value <- po;
|
||||
po |> value;
|
||||
i = i - 1;
|
||||
}
|
||||
|
||||
|
@ -2,14 +2,14 @@
|
||||
// xfail-stage1
|
||||
// xfail-stage2
|
||||
/*
|
||||
This program should hang on the r <- po line.
|
||||
This program should hang on the po |> r line.
|
||||
*/
|
||||
|
||||
fn main() {
|
||||
let port[int] po = port();
|
||||
let chan[int] ch = chan(po);
|
||||
|
||||
auto r; r <- po;
|
||||
auto r; po |> r;
|
||||
|
||||
ch <| 42;
|
||||
|
||||
|
@ -32,7 +32,7 @@ fn main() {
|
||||
let int i;
|
||||
|
||||
// synchronize on event from child.
|
||||
i <- p;
|
||||
p |> i;
|
||||
|
||||
log "parent exiting, killing child";
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ fn main() {
|
||||
spawn a(chan(p));
|
||||
spawn b(chan(p));
|
||||
let int n = 0;
|
||||
n <- p;
|
||||
n <- p;
|
||||
p |> n;
|
||||
p |> n;
|
||||
// log "Finished.";
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,8 @@ fn main() {
|
||||
spawn a(chan(p));
|
||||
spawn b(chan(p));
|
||||
let int n = 0;
|
||||
n <- p;
|
||||
n <- p;
|
||||
p |> n;
|
||||
p |> n;
|
||||
log "Finished.";
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,8 @@ fn main() {
|
||||
let int x = 10;
|
||||
x = g(n,s);
|
||||
log x;
|
||||
n <- p;
|
||||
n <- p;
|
||||
p |> n;
|
||||
p |> n;
|
||||
// FIXME: use signal-channel for this.
|
||||
log "children finished, root finishing";
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ fn main() {
|
||||
let port[int] p = port();
|
||||
spawn child(chan(p));
|
||||
let int y;
|
||||
y <- p;
|
||||
p |> y;
|
||||
log "received";
|
||||
log y;
|
||||
assert (y == 10);
|
||||
|
@ -5,10 +5,10 @@ fn main() {
|
||||
let chan[int] ch = chan(po);
|
||||
|
||||
ch <| 10;
|
||||
let int i; i <- po;
|
||||
let int i; po |> i;
|
||||
assert (i == 10);
|
||||
|
||||
ch <| 11;
|
||||
auto j; j <- po;
|
||||
auto j; po |> j;
|
||||
assert (j == 11);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ io fn check_order(port[order_info] expected_p) {
|
||||
chan(expected_p) <| rec(order=-1, msg="");
|
||||
let mutable int actual = 0;
|
||||
// FIXME #121: Workaround for while(true) bug.
|
||||
auto expected; expected <- expected_p;
|
||||
auto expected; expected_p |> expected;
|
||||
auto done = -1; // FIXME: Workaround for typechecking bug.
|
||||
while(expected.order != done) {
|
||||
if (expected.order != actual) {
|
||||
@ -36,7 +36,7 @@ io fn check_order(port[order_info] expected_p) {
|
||||
fail;
|
||||
}
|
||||
actual += 1;
|
||||
expected <- expected_p;
|
||||
expected_p |> expected;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,13 +9,13 @@ fn main() {
|
||||
let int y;
|
||||
|
||||
spawn child(c);
|
||||
y <- p;
|
||||
p |> y;
|
||||
log "received 1";
|
||||
log y;
|
||||
assert (y == 10);
|
||||
|
||||
spawn child(c);
|
||||
y <- p;
|
||||
p |> y;
|
||||
log "received 2";
|
||||
log y;
|
||||
assert (y == 10);
|
||||
|
@ -9,7 +9,7 @@ fn sub(chan[int] parent, int id) {
|
||||
} else {
|
||||
let port[int] p = port();
|
||||
auto child = spawn sub(chan(p), id-1);
|
||||
let int y; y <- p;
|
||||
let int y; p |> y;
|
||||
parent <| y + 1;
|
||||
}
|
||||
}
|
||||
@ -17,7 +17,7 @@ fn sub(chan[int] parent, int id) {
|
||||
fn main() {
|
||||
let port[int] p = port();
|
||||
auto child = spawn sub(chan(p), 500);
|
||||
let int y <- p;
|
||||
let int p |> y;
|
||||
log "transmission complete";
|
||||
log y;
|
||||
assert (y == 500);
|
||||
|
@ -29,7 +29,7 @@ fn main() {
|
||||
auto w = spawn do_work(chan(p));
|
||||
let int i;
|
||||
log "parent waiting for shutdown";
|
||||
i <- p;
|
||||
p |> i;
|
||||
log "received int";
|
||||
assert (i == 10);
|
||||
log "int is OK, child-dtor ran as expected";
|
||||
|
@ -19,7 +19,7 @@ fn main() {
|
||||
let task s = spawn starve_main(chan(alive));
|
||||
let int i;
|
||||
log "main waiting for alive signal";
|
||||
i <- alive;
|
||||
alive |> i;
|
||||
log "main got alive signal";
|
||||
while (i < 50) {
|
||||
log "main iterated";
|
||||
|
@ -44,7 +44,7 @@ fn test_shrink1() {
|
||||
auto mychan = chan(myport);
|
||||
|
||||
mychan <| 0i8;
|
||||
auto x; x <- myport;
|
||||
auto x; myport |> x;
|
||||
}
|
||||
|
||||
fn test_shrink2() {
|
||||
@ -58,7 +58,7 @@ fn test_shrink2() {
|
||||
}
|
||||
|
||||
for each (uint i in uint::range(0u, 100u)) {
|
||||
auto x; x <- myport;
|
||||
auto x; myport |> x;
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ fn test_rotate() {
|
||||
val3=i as u32);
|
||||
mychan <| val;
|
||||
|
||||
auto x; x <- myport;
|
||||
auto x; myport |> x;
|
||||
assert (x.val1 == i as u32);
|
||||
assert (x.val2 == i as u32);
|
||||
assert (x.val3 == i as u32);
|
||||
@ -95,7 +95,7 @@ fn test_rotate_grow() {
|
||||
}
|
||||
|
||||
for each (uint i in uint::range(0u, 10u)) {
|
||||
auto x; x <- myport;
|
||||
auto x; myport |> x;
|
||||
assert (x.val1 == i as u32);
|
||||
assert (x.val2 == i as u32);
|
||||
assert (x.val3 == i as u32);
|
||||
|
@ -15,8 +15,8 @@ fn test05() {
|
||||
let port[int] po = port();
|
||||
let chan[int] ch = chan(po);
|
||||
spawn test05_start(chan(po));
|
||||
let int value; value <- po;
|
||||
value <- po;
|
||||
value <- po;
|
||||
let int value; po |> value;
|
||||
po |> value;
|
||||
po |> value;
|
||||
assert (value == 30);
|
||||
}
|
||||
|
@ -4,14 +4,14 @@
|
||||
fn start(chan[chan[str]] c) {
|
||||
let port[str] p = port();
|
||||
c <| chan(p);
|
||||
auto a; a <- p;
|
||||
// auto b; b <- p; // Never read the second string.
|
||||
auto a; p |> a;
|
||||
// auto b; p |> b; // Never read the second string.
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let port[chan[str]] p = port();
|
||||
auto child = spawn "start" start(chan(p));
|
||||
auto c; c <- p;
|
||||
auto c; p |> c;
|
||||
c <| "A";
|
||||
c <| "B";
|
||||
yield;
|
||||
|
@ -9,5 +9,5 @@ fn start(chan[chan[str]] c) {
|
||||
fn main() {
|
||||
let port[chan[str]] p = port();
|
||||
auto child = spawn "child" start(chan(p));
|
||||
auto c; c <- p;
|
||||
auto c; p |> c;
|
||||
}
|
||||
|
@ -17,5 +17,5 @@ fn main() {
|
||||
// the child's point of view the receiver may die. We should
|
||||
// drop messages on the floor in this case, and not crash!
|
||||
auto child = spawn thread "child" start(chan(p), 10);
|
||||
auto c; c <- p;
|
||||
auto c; p |> c;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ fn test_rec() {
|
||||
ch <| r0;
|
||||
|
||||
let r r1;
|
||||
r1 <- po;
|
||||
po |> r1;
|
||||
|
||||
assert (r1.val0 == 0);
|
||||
assert (r1.val1 == 1u8);
|
||||
@ -27,7 +27,7 @@ fn test_vec() {
|
||||
ch <| v0;
|
||||
|
||||
let vec[int] v1;
|
||||
v1 <- po;
|
||||
po |> v1;
|
||||
|
||||
assert (v1.(0) == 0);
|
||||
assert (v1.(1) == 1);
|
||||
@ -42,7 +42,7 @@ fn test_str() {
|
||||
ch <| s0;
|
||||
|
||||
let str s1;
|
||||
s1 <- po;
|
||||
po |> s1;
|
||||
|
||||
assert (s1.(0) as u8 == 't' as u8);
|
||||
assert (s1.(1) as u8 == 'e' as u8);
|
||||
@ -60,7 +60,7 @@ fn test_tup() {
|
||||
ch <| t0;
|
||||
|
||||
let t t1;
|
||||
t1 <- po;
|
||||
po |> t1;
|
||||
|
||||
assert (t0._0 == 0);
|
||||
assert (t0._1 == 1u8);
|
||||
@ -83,11 +83,11 @@ fn test_tag() {
|
||||
|
||||
let t t1;
|
||||
|
||||
t1 <- po;
|
||||
po |> t1;
|
||||
assert (t1 == tag1);
|
||||
t1 <- po;
|
||||
po |> t1;
|
||||
assert (t1 == tag2(10));
|
||||
t1 <- po;
|
||||
po |> t1;
|
||||
assert (t1 == tag3(10, 11u8, 'A'));
|
||||
}
|
||||
|
||||
@ -101,13 +101,13 @@ fn test_chan() {
|
||||
ch <| ch0;
|
||||
|
||||
let chan[int] ch1;
|
||||
ch1 <- po;
|
||||
po |> ch1;
|
||||
|
||||
// Does the transmitted channel still work?
|
||||
ch1 <| 10;
|
||||
|
||||
let int i;
|
||||
i <- po0;
|
||||
po0 |> i;
|
||||
|
||||
assert (i == 10);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ fn test00(bool is_multithreaded) {
|
||||
for (task t in tasks) {
|
||||
i = 0;
|
||||
while (i < number_of_messages) {
|
||||
let int value; value <- po;
|
||||
let int value; po |> value;
|
||||
sum += value;
|
||||
i = i + 1;
|
||||
}
|
||||
|
@ -13,20 +13,20 @@ fn test00() {
|
||||
c <| 3;
|
||||
c <| 4;
|
||||
|
||||
r <- p; sum += r; log (r);
|
||||
r <- p; sum += r; log (r);
|
||||
r <- p; sum += r; log (r);
|
||||
r <- p; sum += r; log (r);
|
||||
p |> r; sum += r; log (r);
|
||||
p |> r; sum += r; log (r);
|
||||
p |> r; sum += r; log (r);
|
||||
p |> r; sum += r; log (r);
|
||||
|
||||
c <| 5;
|
||||
c <| 6;
|
||||
c <| 7;
|
||||
c <| 8;
|
||||
|
||||
r <- p; sum += r; log (r);
|
||||
r <- p; sum += r; log (r);
|
||||
r <- p; sum += r; log (r);
|
||||
r <- p; sum += r; log (r);
|
||||
p |> r; sum += r; log (r);
|
||||
p |> r; sum += r; log (r);
|
||||
p |> r; sum += r; log (r);
|
||||
p |> r; sum += r; log (r);
|
||||
|
||||
assert (sum == 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8);
|
||||
}
|
@ -17,7 +17,7 @@ fn test00() {
|
||||
|
||||
i = 0;
|
||||
while (i < number_of_messages) {
|
||||
r <- p; sum += r;
|
||||
p |> r; sum += r;
|
||||
i += 1;
|
||||
}
|
||||
|
||||
|
@ -25,10 +25,10 @@ fn test00() {
|
||||
|
||||
i = 0;
|
||||
while (i < number_of_messages) {
|
||||
r <- p; sum += r;
|
||||
r <- p; sum += r;
|
||||
r <- p; sum += r;
|
||||
r <- p; sum += r;
|
||||
p |> r; sum += r;
|
||||
p |> r; sum += r;
|
||||
p |> r; sum += r;
|
||||
p |> r; sum += r;
|
||||
i += 1;
|
||||
}
|
||||
|
||||
|
@ -30,10 +30,10 @@ fn test00() {
|
||||
|
||||
let int i = 0;
|
||||
while (i < number_of_messages) {
|
||||
r <- p; sum += r;
|
||||
r <- p; sum += r;
|
||||
r <- p; sum += r;
|
||||
r <- p; sum += r;
|
||||
p |> r; sum += r;
|
||||
p |> r; sum += r;
|
||||
p |> r; sum += r;
|
||||
p |> r; sum += r;
|
||||
i += 1;
|
||||
}
|
||||
|
||||
|
@ -30,10 +30,10 @@ fn test00() {
|
||||
|
||||
let int i = 0;
|
||||
while (i < number_of_messages) {
|
||||
r <- p; sum += r;
|
||||
r <- p; sum += r;
|
||||
r <- p; sum += r;
|
||||
r <- p; sum += r;
|
||||
p |> r; sum += r;
|
||||
p |> r; sum += r;
|
||||
p |> r; sum += r;
|
||||
p |> r; sum += r;
|
||||
i += 1;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ fn test00() {
|
||||
|
||||
let int i = 0;
|
||||
while (i < number_of_messages) {
|
||||
r <- p; sum += r; log (r);
|
||||
p |> r; sum += r; log (r);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ fn main() {
|
||||
ch <| ();
|
||||
|
||||
let () n;
|
||||
n <- po;
|
||||
po |> n;
|
||||
|
||||
assert (n == ());
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ fn test00(bool is_multithreaded) {
|
||||
for (task t in tasks) {
|
||||
i = 0;
|
||||
while (i < number_of_messages) {
|
||||
let int value; value <- po;
|
||||
let int value; po |> value;
|
||||
sum += value;
|
||||
i = i + 1;
|
||||
}
|
||||
@ -66,7 +66,7 @@ fn test00(bool is_multithreaded) {
|
||||
fn test01() {
|
||||
let port[int] p = port();
|
||||
log "Reading from a port that is never written to.";
|
||||
let int value; value <- p;
|
||||
let int value; p |> value;
|
||||
log value;
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ fn test02() {
|
||||
log "Writing to a local task channel.";
|
||||
c <| 42;
|
||||
log "Reading from a local task port.";
|
||||
let int value; value <- p;
|
||||
let int value; p |> value;
|
||||
log value;
|
||||
}
|
||||
|
||||
@ -126,9 +126,9 @@ fn test05() {
|
||||
let port[int] po = port();
|
||||
let chan[int] ch = chan(po);
|
||||
spawn thread test05_start(ch);
|
||||
let int value; value <- po;
|
||||
value <- po;
|
||||
value <- po;
|
||||
let int value; po |> value;
|
||||
po |> value;
|
||||
po |> value;
|
||||
log value;
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ fn main() {
|
||||
|
||||
ch <| 42;
|
||||
|
||||
auto r; r <- po;
|
||||
auto r; po |> r;
|
||||
|
||||
log_err r;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user