From a780ce4f58dbe2bef7af247dea3bea28961b4e37 Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Thu, 10 Oct 2024 22:40:37 +0200 Subject: [PATCH] doc: note that @-pattern is accessible in default values --- doc/manual/src/language/syntax.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/doc/manual/src/language/syntax.md b/doc/manual/src/language/syntax.md index 506afbea1..a96a3b2cc 100644 --- a/doc/manual/src/language/syntax.md +++ b/doc/manual/src/language/syntax.md @@ -503,6 +503,23 @@ three kinds of patterns: > [ 23 {} ] > ``` + The complete function argument denoted as an `@`-pattern can be accessed inside 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.,