Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: note that @-pattern is accessible in default values #11672

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions doc/manual/src/language/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,24 @@ three kinds of patterns:
> [ 23 {} ]
> ```

The full function argument bound by the `@`-pattern is also brought into scope over the set pattern on the other side of the `@`, not just over the body of the function.
Mic92 marked this conversation as resolved.
Show resolved Hide resolved
It can therefore be used in default values.

> **Example**
>
> ```nix
> let
> f = args@{ x ? args.a, ... }: x;
> in
> f { a = 1; }
> ```
>
> evaluates to
>
> ```nix
> 1
> ```

Note that functions do not have names. If you want to give them a name,
you can bind them to an attribute, e.g.,

Expand Down
Loading