From 1bac7a10e64049361f4ebdb592aa07ad3dbb4c53 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 7 Nov 2004 18:58:49 +0000 Subject: * Operators, comments. --- doc/manual/writing-nix-expressions.xml | 125 ++++++++++++++++++++++++++++++++- 1 file changed, 123 insertions(+), 2 deletions(-) diff --git a/doc/manual/writing-nix-expressions.xml b/doc/manual/writing-nix-expressions.xml index d81d741a8..ac7b24c24 100644 --- a/doc/manual/writing-nix-expressions.xml +++ b/doc/manual/writing-nix-expressions.xml @@ -933,14 +933,126 @@ used in the Nix expression for Subversion. With expressions -TODO +A with expression, + + +with e1; e2 + +introduces the attribute set e1 into the +lexical scope of the expression e2. For +instance, + + +let { + as = {x = "foo"; y = "bar";}; + + body = with as; x + y; +} + +evaluates to "foobar" since the +with adds the x and +y attributes of as to the +lexical scope in the expression x + y. The most +common use of with is in conjunction with the +import function. E.g., + + +with (import ./definitions.nix); ... + +makes all attributes defined in the file +definitions.nix available as if they were defined +locally in a rec-expression. Operators -TODO + lists the operators in the +Nix expression language, in order of precedence (from strongest to +weakest binding). + + + Operators + + + + Syntax + Associativity + Description + + + + + e1 ~ e2 + none + Construct a reference to a subpath of a derivation. + E.g., hello ~ "/bin/sh" refers to the + /bin/sh path within the Hello derivation. + Useful in specifying derivation attributes. + + + e ? + id + none + Test whether attribute set e + contains an attribute named + id. + + + e1 + e2 + left + String or path concatenation. + + + ! e + left + Boolean negation. + + + e1 // + e2 + right + Return an attribute set consisting of the attributes in + e1 and + e2 (with the latter taking + precedence over the former in case of equally named attributes). + + + e1 == + e2 + none + Equality. + + + e1 != + e2 + none + Inequality. + + + e1 && + e2 + left + Logical AND. + + + e1 || + e2 + left + Logical OR. + + + e1 -> + e2 + none + Logical implication (equivalent to + !e1 || + e2). + + + +
@@ -959,6 +1071,15 @@ used in the Nix expression for Subversion. +Comments + +Comments can be single-line, started with a # +character, or inline/multi-line, enclosed within /* +... */. + + + + -- cgit v1.2.3