The expression `with E1; E2' evaluates to E2 with all bindings in
the attribute set E1 substituted. E.g.,
with {x = 123;}; x
evaluates to 123. That is, the attribute set E1 is in scope in E2.
This is particularly useful when importing files containing lots
definitions. E.g., instead of
let {
inherit (import ./foo.nix) a b c d e f;
body = ... a ... f ...;
}
we can now say
with import ./foo.nix;
... a ... f ...
I.e., we don't have to say what variables should be brought into scope.
|
||
|---|---|---|
| .. | ||
| bugs.xml | ||
| installation.xml | ||
| introduction.xml | ||
| Makefile.am | ||
| manual.xml | ||
| nix-collect-garbage.xml | ||
| nix-env.xml | ||
| nix-instantiate.xml | ||
| nix-lang-ref.xml | ||
| nix-prefetch-url.xml | ||
| nix-pull.xml | ||
| nix-push.xml | ||
| nix-store.xml | ||
| opt-common-syn.xml | ||
| opt-common.xml | ||
| package-management.xml | ||
| quick-start.xml | ||
| schemas.xml | ||
| style.css | ||
| troubleshooting.xml | ||
| writing-nix-expressions.xml | ||