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 4 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 {} ]
> ```

All bindings introduced by the function are in scope in the entire function expression; not just in the body. For example, the binding of an `@` pattern is available in the `?`-defaults:
It can therefore be used in default values.

> **Example**
>
fricklerhandwerk marked this conversation as resolved.
Show resolved Hide resolved
> ```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