about summary refs log tree commit diff
path: root/src/libexpr/nixexpr.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-04-13T13·42+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-04-13T13·42+0000
commit7d47498b5ea1ad4685bad954e5407f628f7f5595 (patch)
tree0451c3cd9301030af94a805f476d8b5926edd4d6 /src/libexpr/nixexpr.cc
parentac1e8f40d4a5c380d68bb6f1c7cef6f1e7987c1a (diff)
* Evaluate lets directly (i.e. without desugaring to `rec { attrs...;
  <let-body> = e; }.<let-body>).  This prevents the unnecessary
  allocation of an attribute set.

Diffstat (limited to 'src/libexpr/nixexpr.cc')
-rw-r--r--src/libexpr/nixexpr.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc
index 922066c234a4..0abc2a457304 100644
--- a/src/libexpr/nixexpr.cc
+++ b/src/libexpr/nixexpr.cc
@@ -87,6 +87,16 @@ void ExprLambda::show(std::ostream & str)
     str << ": " << *body << ")";
 }
 
+void ExprLet::show(std::ostream & str)
+{
+    str << "let ";
+    foreach (list<Symbol>::iterator, i, attrs->inherited)
+        str << "inherit " << *i << "; ";
+    foreach (ExprAttrs::Attrs::iterator, i, attrs->attrs)
+        str << i->first << " = " << *i->second << "; ";
+    str << "in " << *body;
+}
+
 void ExprWith::show(std::ostream & str)
 {
     str << "with " << *attrs << "; " << *body;