title | parent |
---|---|
With Expression |
Control-Related-Expressions.md |
'with' param_list 'in' map_expr block_expr
Note that in contrast to most imperative languages like C/C++ or Java, a with
-construct is not a statement but an expression and, thus, yields a value.
A with
-expression is syntactic sugar for:
f(args, |param_list, break| -> ! block_expr)
Suppose f
has type:
fn(A, fn(I) -> B) -> R
args
must be of type A
and param_list
of type I
.
Additionally, Impala implicitly declares the following continuation which is usable inside block_expr
:
-
break
of typefn(B) -> !
This is the return-continuation of the call to
f
. Thus, invoking this continuation returns from the current Function Expression with a value of typeB
.
Since block_expr
also exits the current Function Expression, its type must be B
, too.
The type of the whole with
expression is R
- whatever is yielded by invoking f
.
Since a with
expression is just syntactic sugar, see Map Expression.
TODO