From 733214144a7a910001c1c82683db780853bac9b1 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Wed, 22 Jan 2014 00:33:18 +0000 Subject: Document dynamic attributes Signed-off-by: Shea Levy --- doc/manual/release-notes.xml | 6 ++++++ doc/manual/writing-nix-expressions.xml | 21 +++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) (limited to 'doc') diff --git a/doc/manual/release-notes.xml b/doc/manual/release-notes.xml index 37bb730f4..56f7bd654 100644 --- a/doc/manual/release-notes.xml +++ b/doc/manual/release-notes.xml @@ -21,6 +21,12 @@ nix-setuid-helper is gone. + Now antiquotation is allowed inside of quoted + attribute names (e.g. set."${foo}"). In the + case where the attribute name is just a single antiquotation, + the quotes can be dropped (e.g. the above example can be written + set.${foo}). + diff --git a/doc/manual/writing-nix-expressions.xml b/doc/manual/writing-nix-expressions.xml index c5b355ea0..71cd84b07 100644 --- a/doc/manual/writing-nix-expressions.xml +++ b/doc/manual/writing-nix-expressions.xml @@ -851,13 +851,26 @@ default value in an attribute selection using the will evaluate to "Xyzzy" because there is no c attribute in the set. -You can use arbitrary string constants as attribute names by -enclosing them in quotes: +You can use arbitrary double-quoted strings as attribute +names: -{ "foo bar" = 123; "nix-1.0" = 456; }."foo bar" +{ "foo ${bar}" = 123; "nix-1.0" = 456; }."foo ${bar}" + + +This will evaluate to 123 (Assuming +bar is antiquotable). In the case where an +attribute name is just a single antiquotation, the quotes can be +dropped: + + +{ foo = 123; }.${bar} or 456 + +This will evaluate to 123 if +bar evaluates to "foo" when +coerced to a string and 456 otherwise (again +assuming bar is antiquotable). -This will evaluate to 123. -- cgit v1.2.3