1
Fork 0

Make 'lambda(...) -> ...' parse as a type

This commit is contained in:
Marijn Haverbeke 2011-11-02 11:42:31 +01:00
parent 4e9b8a28f7
commit eaf9e05611
2 changed files with 10 additions and 26 deletions

View file

@ -25,13 +25,10 @@ expected to return.
## Closures
FIXME Either move entirely to fn~/fn@ nomenclature, or fix compiler to
accept lambda as a type
Normal Rust functions (declared with `fn`) do not close over their
environment. A `lambda` expression can be used to create a closure.
fn make_plus_function(x: int) -> fn@(int) -> int {
fn make_plus_function(x: int) -> lambda(int) -> int {
lambda(y: int) -> int { x + y }
}
let plus_two = make_plus_function(2);