| 6 Jun 2021 |
ianf | Actually, misread $ as @ lol | 18:57:22 |
andrew | Is it possible to get an output showing nix's grammar summary similar to how this stale issue suggests? https://github.com/NixOS/nix/pull/402 | 21:50:11 |
andrew | Or is the grammar summary documented somewhere? | 21:51:03 |
infinisil | andrew: Well the parser specification is here: https://github.com/NixOS/nix/blob/master/src/libexpr/parser.y | 21:51:49 |
andrew | thanks, reading | 21:52:55 |
| 7 Jun 2021 |
andrew | Are there any ways to pass a variable to a more specific scope other than "let-in" a the inherit keyword? | 03:42:46 |
andrew | * Are there any ways to pass a variable to a sub-scope other than "let-in" a the inherit keyword? | 03:43:03 |
andrew | * Are there any ways to pass a variable to a sub-scope other than "let-in" or the inherit keyword? | 03:43:14 |
siraben | andrew: with? | 03:45:11 |
siraben | note: with + let interaction can be surprising | 03:45:38 |
andrew | raght that too | 03:45:49 |
andrew | * right that too | 03:46:11 |
andrew | hmm what do you mean? One of the let statements overrides the other if an attribute is +'d? | 03:46:35 |
andrew | Redacted or Malformed Event | 03:48:46 |
| andrew | 07:48:11 |
siraben | andrew: what do you think let a = 3; in with { a = 5; }; a prints | 10:00:16 |
siraben | * andrew: what do you think let a = 3; in with { a = 5; }; a evaluates to | 10:00:21 |
siraben | if we had full lexical scope like in most functional languages, we would expect 5 | 10:00:59 |
siraben | however that evaluates to 3 in Nix. | 10:01:03 |
andrew | so let statements take precedence over with statements? | 10:01:40 |
sterni | with set; x couldn't be lexically scoped since the content of a couldn't be determined lexically | 10:01:53 |
sterni | andrew: with won't ever shadow anything that is in scope basically | 10:02:04 |
andrew | oh with + let, not with + let | 10:02:35 |
sterni | however it seems that with will shadow existing with bindings | 10:02:50 |
andrew | so with never overrides any variables in the scope | 10:03:06 |
sterni | nix-repl> let x = { a = 12; }; y = { a = 13; }; in with x; with y; a
13
| 10:03:07 |
sterni | andrew: nothing that is bound lexically I guess, like a function argument or a let binding | 10:03:36 |
andrew | what will it override? | 10:04:10 |
andrew | Redacted or Malformed Event | 10:04:17 |
sterni | also it won't shadow anything that is bound via a rec { } set | 10:04:33 |