Nix Language Quirks: Difference between revisions
imported>Fricklerhandwerk No edit summary |
imported>Fricklerhandwerk @ syntax does not bind default values |
||
| Line 33: | Line 33: | ||
Note, that it isn't equivalent to <code>with rec { x = 1; y = x + 1; body = y; }; body</code> because of mentioned <code>with</code> and <code>let</code> quirk, but is same as <code>rec { x = 1; y = x + 1; body = y; }.body</code> | Note, that it isn't equivalent to <code>with rec { x = 1; y = x + 1; body = y; }; body</code> because of mentioned <code>with</code> and <code>let</code> quirk, but is same as <code>rec { x = 1; y = x + 1; body = y; }.body</code> | ||
== Default values are not bound in @ syntax == | |||
Destructured arguments can have default values, but those default values are part of the full function argument. | |||
In the following example, calling the function that binds a default value <code>"a"</code> to the argument's attribute <code>a</code> with an empty attribute set as argument will produce an empty attribute set <code>args</code> instead of <code>{ a = "a"; }</code>: | |||
<syntaxHighlight lang=nix> | |||
(args@{a ? "a"}: args) {} | |||
</syntaxHighlight> | |||
<code>{ }</code> | |||
Related: [https://github.com/NixOS/nix/issues/1461 GitHub issue filed 2017] | |||
== Something that looks like both record attribute and <code>let</code>-binding == | == Something that looks like both record attribute and <code>let</code>-binding == | ||