tazjin/nix-1p

Confusing what the scope of `with` is.

Closed this issue · 2 comments

In https://github.com/tazjin/nix-1p#with-statements

For me, it was a bit confusing what kind of thing with is. What I understood from the current explanation in my own words:

with <attr> is an expression which can precede an expression to put all members of into its scope:

nix-repl> let x = 7; attr = {a = 5;}; in x + (with attr; a)
12

However from my experiments with the repl, it only looks like an expression (because it is followed by ;), but it is not.

tazjin commented

Do you think this change would clarify it? https://cl.tvl.fyi/c/depot/+/8951/

This looks better, thank you!