about summary refs log tree commit diff
path: root/src/libexpr/nixexpr.hh
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2011-07-13T12·19+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2011-07-13T12·19+0000
commit0a623a10c7e89a80b6dc74445a0ae6240f65723e (patch)
tree1c7a415095c4851c69d9b4c5dd1fea46a961a37c /src/libexpr/nixexpr.hh
parent2b9e29b1c8b6b8e4884a46a3ba71ee795f1f97cd (diff)
* Allow a default value in attribute selection by writing
    x.y.z or default

  (as originally proposed in
  https://mail.cs.uu.nl/pipermail/nix-dev/2009-September/002989.html).

  For instance, an expression like

    stdenv.lib.attrByPath ["features" "ckSched"] false args

  can now be written as

    args.features.ckSched or false


Diffstat (limited to 'src/libexpr/nixexpr.hh')
-rw-r--r--src/libexpr/nixexpr.hh6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh
index 725e30c6fa6d..166289b29851 100644
--- a/src/libexpr/nixexpr.hh
+++ b/src/libexpr/nixexpr.hh
@@ -121,10 +121,10 @@ struct ExprVar : Expr
 
 struct ExprSelect : Expr
 {
-    Expr * e;
+    Expr * e, * def;
     AttrPath attrPath;
-    ExprSelect(Expr * e, const AttrPath & attrPath) : e(e), attrPath(attrPath) { };
-    ExprSelect(Expr * e, const Symbol & name) : e(e) { attrPath.push_back(name); };
+    ExprSelect(Expr * e, const AttrPath & attrPath, Expr * def) : e(e), def(def), attrPath(attrPath) { };
+    ExprSelect(Expr * e, const Symbol & name) : e(e), def(0) { attrPath.push_back(name); };
     COMMON_METHODS
 };