-
Notifications
You must be signed in to change notification settings - Fork 3
With Statement
Matt Bierner edited this page Apr 8, 2014
·
5 revisions
Khepri modifies the ECMASscript with
statement to be a statement level let expression.
with x = 10, y = 5 in {
if (x > y)
return x;
return y;
}
Unlike the let
statement, with
statements can contain any flow control statements like return
, throw
, break
, and continue
. The body of a with statement must be a block statement.
With statements bindings may use any unpack, following the same rules as let expressions. All bindings are immutable and only valid inside of the body.
With statements bindings also allow a special syntax for importing a package
with
import 'lib/math' math#{min max},
import 'lib/str' {match search}
{
return math.min(math.max(10, 4), 5);
}
The import pattern takes a string package name and any unpack. It tries to load the given package and unpacks its value.