Created
March 7, 2013 20:50
-
-
Save bstrie/5111674 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn outer1(i: &mut int) { | |
if *i < 9 { | |
*i += 1; | |
outer2(i); | |
} | |
} | |
fn outer2(i: &mut int) { | |
*i += 1; | |
outer1(i); | |
} | |
fn main() { | |
let mut foo = 0; | |
outer1(&mut foo); | |
io::println(fmt!("%d", foo)); // prints "10" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
fn outer1(i: &mut int) { | |
if *i < 9 { | |
*i += 1; | |
outer2(i); | |
} | |
} | |
fn outer2(i: &mut int) { | |
*i += 1; | |
outer1(i); | |
} | |
let mut foo = 0; | |
outer1(&mut foo); | |
io::println(fmt!("%d", foo)); // prints "10" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let bar = 1; | |
fn outer1(i: &mut int) { | |
if *i < 9 { | |
*i += bar; // error: attempted dynamic environment-capture | |
outer2(i); | |
} | |
} | |
fn outer2(i: &mut int) { | |
*i += bar; // error: attempted dynamic environment-capture | |
outer1(i); | |
} | |
let mut foo = 0; | |
outer1(&mut foo); | |
io::println(fmt!("%d", foo)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let bar = 1; | |
let outer1 = |i| { | |
if *i < 9 { | |
*i += bar; | |
outer2(i); // error: unresolved name: outer2 | |
} | |
}; | |
let outer2 = |i| { | |
*i += bar; | |
outer1(i); | |
}; | |
let mut foo = 0; | |
io::println(fmt!("%d", foo)); | |
outer1(&mut foo); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment