You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alex Rønne Petersen edited this page Jun 5, 2013
·
2 revisions
In Flect, every block (enclosed by { and }) has a value which corresponds to the last expression in the block. For example, this is valid:
pub fn foo() -> int {
let x = {
42;
};
x;
}
Or even the somewhat obscure version:
pub fn foo() -> int {
{
42;
};
}
Further, all expressions that use blocks (such as if) have values:
pub fn foo(i : int) -> bool {
if i == 42 {
true
} else {
false
};
}
Some expressions (such as for) have no sensible result value, so they return the unit value.
Blocks themselves are not values in the sense that they can be passed to other functions. They can, however, be passed to macros in order to create what looks like new syntax. For instance: