From 5bc41d78ffcd2952eaddb20ef129f48e94d60cb0 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 24 Oct 2013 16:41:04 +0200 Subject: [PATCH] Rename "attribute sets" to "sets" We don't have any other kind of sets so calling them attribute sets is unnecessarily verbose. --- doc/manual/builtins.xml | 82 +++++++++---------- doc/manual/nix-env.xml | 11 ++- doc/manual/writing-nix-expressions.xml | 106 ++++++++++++------------- src/libexpr/attr-path.cc | 7 +- src/libexpr/eval-inline.hh | 2 +- src/libexpr/eval.cc | 23 +++--- src/libexpr/eval.hh | 4 +- src/libexpr/get-drvs.cc | 22 +++-- src/libexpr/nixexpr.hh | 4 +- src/libexpr/primops.cc | 30 +++---- src/libexpr/symbol-table.hh | 9 +-- src/nix-env/nix-env.cc | 10 +-- tests/lang/eval-okay-types.exp | 2 +- 13 files changed, 152 insertions(+), 160 deletions(-) diff --git a/doc/manual/builtins.xml b/doc/manual/builtins.xml index ce21e8525..42fcd70eb 100644 --- a/doc/manual/builtins.xml +++ b/doc/manual/builtins.xml @@ -12,9 +12,9 @@ such as derivation, are always in scope of every Nix expression; you can just access them right away. But to prevent polluting the namespace too much, most built-ins are not in scope. Instead, you can access them through the builtins -built-in value, which is an attribute set that contains all built-in -functions and values. For instance, derivation -is also available as builtins.derivation. +built-in value, which is a set that contains all built-in functions +and values. For instance, derivation is also +available as builtins.derivation. @@ -39,14 +39,14 @@ is also available as builtins.derivation. builtins.attrNames - attrs + set - Return the names of the attributes in the - attribute set attrs in a sorted list. - For instance, builtins.attrNames { y = 1; x = "foo"; - } evaluates to [ "x" "y" ]. There is - no built-in function attrValues, but you can - easily define it yourself: + Return the names of the attributes in the set + set in a sorted list. For instance, + builtins.attrNames { y = 1; x = "foo"; } + evaluates to [ "x" "y" ]. There is no built-in + function attrValues, but you can easily + define it yourself: attrValues = attrs: map (name: builtins.getAttr name attrs) (builtins.attrNames attrs); @@ -68,8 +68,8 @@ attrValues = attrs: map (name: builtins.getAttr name attrs) (builtins.attrNames builtins - The attribute set builtins - contains all the built-in functions and values. You can use + The set builtins contains all + the built-in functions and values. You can use builtins to test for the availability of features in the Nix installation, e.g., @@ -258,11 +258,11 @@ stdenv.mkDerivation { builtins.getAttr - s attrs + s set getAttr returns the attribute - named s from the attribute set - attrs. Evaluation aborts if the + named s from + set. Evaluation aborts if the attribute doesn’t exist. This is a dynamic version of the . operator, since s is an expression rather than an identifier. @@ -289,15 +289,15 @@ stdenv.mkDerivation { builtins.hasAttr - s attrs + s set hasAttr returns - true if the attribute set - attrs has an attribute named - s, and false - otherwise. This is a dynamic version of the ? - operator, since s is an expression - rather than an identifier. + true if set has an + attribute named s, and + false otherwise. This is a dynamic version of + the ? operator, since + s is an expression rather than an + identifier. @@ -331,12 +331,12 @@ stdenv.mkDerivation { Load, parse and return the Nix expression in the file path. If path is a directory, the file default.nix - in that directory is loaded. Evaluation aborts if - the file doesn’t exist or contains an incorrect Nix - expression. import implements Nix’s module - system: you can put any Nix expression (such as an attribute set - or a function) in a separate file, and use it from Nix expressions - in other files. + in that directory is loaded. Evaluation aborts if the + file doesn’t exist or contains an incorrect Nix expression. + import implements Nix’s module system: you + can put any Nix expression (such as a set or a function) in a + separate file, and use it from Nix expressions in other + files. A Nix expression loaded by import must not contain any free variables (identifiers @@ -383,9 +383,9 @@ x: x + 456 builtins.intersectAttrs e1 e2 - Return an attribute set consisting of the - attributes in the set e2 that also - exist in the set e1. + Return a set consisting of the attributes in the + set e2 that also exist in the set + e1. @@ -394,7 +394,7 @@ x: x + 456 e Return true if - e evaluates to an attribute set, and + e evaluates to a set, and false otherwise. @@ -490,9 +490,9 @@ x: x + 456 builtins.listToAttrs e - Construct an attribute set from a list specifying - the names and values of each attribute. Each element of the list - should be an attribute set consisting of a string-valued attribute + Construct a set from a list specifying the names + and values of each attribute. Each element of the list should be + a set consisting of a string-valued attribute name specifying the name of the attribute, and an attribute value specifying its value. Example: @@ -547,7 +547,7 @@ map (x: "foo" + x) [ "bar" "bla" "abc" ] a package name and version. The package name is everything up to but not including the first dash followed by a digit, and the version is everything following that dash. The result is returned - in an attribute set { name, version }. Thus, + in a set { name, version }. Thus, builtins.parseDrvName "nix-0.12pre12876" returns { name = "nix"; version = "0.12pre12876"; }. @@ -598,12 +598,12 @@ in config.someSetting removeAttrs - attrs list + set list Remove the attributes listed in - list from the attribute set - attrs. The attributes don’t have to - exist in attrs. For instance, + list from + set. The attributes don’t have to + exist in set. For instance, removeAttrs { x = 1; y = 2; z = 3; } [ "a" "x" "z" ] @@ -792,7 +792,7 @@ in foo servlet container. A servlet container contains a number of servlets (*.war files) each exported under a specific URI prefix. So the servlet configuration is a list of - attribute sets containing the path and + sets containing the path and war of the servlet (). This kind of information is difficult to communicate with the normal method of passing diff --git a/doc/manual/nix-env.xml b/doc/manual/nix-env.xml index 03111515a..5f87093ac 100644 --- a/doc/manual/nix-env.xml +++ b/doc/manual/nix-env.xml @@ -153,11 +153,10 @@ also . default. The Nix expressions in this directory are combined into a - single attribute set, with each file as an attribute that has the - name of the file. Thus, if ~/.nix-defexpr - contains two files, foo and - bar, then the default Nix expression will - essentially be + single set, with each file as an attribute that has the name of + the file. Thus, if ~/.nix-defexpr contains + two files, foo and bar, + then the default Nix expression will essentially be { @@ -405,7 +404,7 @@ $ nix-env -f ./foo.nix -i -E \ I.e., this evaluates to (f: (f {system = "i686-linux";}).subversionWithJava) (import ./foo.nix), thus selecting the subversionWithJava attribute from the -attribute set returned by calling the function defined in +set returned by calling the function defined in ./foo.nix. A dry-run tells you which paths will be downloaded or built from diff --git a/doc/manual/writing-nix-expressions.xml b/doc/manual/writing-nix-expressions.xml index 5ba3df56c..415492626 100644 --- a/doc/manual/writing-nix-expressions.xml +++ b/doc/manual/writing-nix-expressions.xml @@ -118,10 +118,10 @@ the single Nix expression in that directory stdenv.mkDerivation. mkDerivation is a function provided by stdenv that builds a package from a set of - attributes. An attribute set is just a list - of key/value pairs where each value is an arbitrary Nix - expression. They take the general form - { name1 = + attributes. A set is just a list of + key/value pairs where each key is a string and each value is an + arbitrary Nix expression. They take the general form { + name1 = expr1; ... nameN = exprN; }. @@ -384,9 +384,9 @@ some fragments of This is where the actual composition takes place. Here we call the function imported from - ../applications/misc/hello/ex-1 with an - attribute set containing the things that the function expects, - namely fetchurl, stdenv, and + ../applications/misc/hello/ex-1 with a set + containing the things that the function expects, namely + fetchurl, stdenv, and perl. We use inherit again to use the attributes defined in the surrounding scope (we could also have written fetchurl = fetchurl;, etc.). @@ -805,20 +805,21 @@ to be enclosed in parentheses. If they had been omitted, e.g., [ 123 ./foo.nix "abc" f { x = y; } ] the result would be a list of five elements, the fourth one being a -function and the fifth being an attribute set. +function and the fifth being a set. -Attribute sets +Sets -Attribute sets are really the core of the language, since -ultimately it's all about creating derivations, which are really just +Sets are really the core of the language, since ultimately the +Nix language is all about creating derivations, which are really just sets of attributes to be passed to build scripts. -Attribute sets are just a list of name/value pairs enclosed in -curly brackets, where each value is an arbitrary expression terminated -by a semicolon. For example: +Sets are just a list of name/value pairs (called +attributes) enclosed in curly brackets, where +each value is an arbitrary expression terminated by a semicolon. For +example: { x = 123; @@ -826,12 +827,12 @@ by a semicolon. For example: y = f { bla = 456; }; } -This defines an attribute set with attributes named -x, text, y. -The order of the attributes is irrelevant. An attribute name may only -occur once. +This defines a set with attributes named x, +text, y. The order of the +attributes is irrelevant. An attribute name may only occur +once. -Attributes can be selected from an attribute set using the +Attributes can be selected from a set using the . operator. For instance, @@ -864,10 +865,10 @@ This will evaluate to 123.
Language constructs -Recursive attribute sets +Recursive sets -Recursive attribute sets are just normal attribute sets, but the -attributes can refer to each other. For example, +Recursive sets are just normal sets, but the attributes can +refer to each other. For example, rec { @@ -880,11 +881,11 @@ evaluates to 123. Note that without rec the binding x = y; would refer to the variable y in the surrounding scope, if one exists, and would be invalid if no such variable exists. That -is, in a normal (non-recursive) attribute set, attributes are not -added to the lexical scope; in a recursive set, they are. +is, in a normal (non-recursive) set, attributes are not added to the +lexical scope; in a recursive set, they are. -Recursive attribute sets of course introduce the danger of -infinite recursion. For example, +Recursive sets of course introduce the danger of infinite +recursion. For example, rec { @@ -918,16 +919,16 @@ evaluates to "foobar". let { attrs }, which is translated to rec { attrs }.body. That is, the body of the let-expression is the -body attribute of the attribute set. +body attribute of the set. Inheriting attributes -When defining an attribute set it is often convenient to copy -variables from the surrounding lexical scope (e.g., when you want to -propagate attributes). This can be shortened using the +When defining a set it is often convenient to copy variables +from the surrounding lexical scope (e.g., when you want to propagate +attributes). This can be shortened using the inherit keyword. For instance, @@ -936,10 +937,10 @@ let x = 123; in y = 456; } -evaluates to { x = 123; y = 456; }. (Note that this -works because x is added to the lexical scope by -the let construct.) It is also possible to inherit -attributes from another attribute set. For instance, in this fragment +evaluates to { x = 123; y = 456; }. (Note that +this works because x is added to the lexical scope +by the let construct.) It is also possible to +inherit attributes from another set. For instance, in this fragment from all-packages.nix, @@ -958,13 +959,12 @@ from all-packages.nix, libjpg = ...; ... -the attribute set used in the function call to the function defined in +the set used in the function call to the function defined in ../tools/graphics/graphviz inherits a number of variables from the surrounding scope (fetchurl ... yacc), but also inherits libXaw (the X Athena Widgets) from the -xlibs (X11 client-side libraries) attribute -set. +xlibs (X11 client-side libraries) set. @@ -1003,11 +1003,11 @@ map (concat "foo") [ "bar" "bla" "abc" ] "fooabc" ]. - An attribute set pattern of the - form { name1, name2, …, nameN } - matches an attribute set containing the listed attributes, and binds - the values of those attributes to variables in the function body. - For example, the function + A set pattern of the form + { name1, name2, …, nameN } matches a set + containing the listed attributes, and binds the values of those + attributes to variables in the function body. For example, the + function { x, y, z }: z + y + x @@ -1174,9 +1174,8 @@ used in the Nix expression for Subversion. with e1; e2 -introduces the attribute set e1 into the -lexical scope of the expression e2. For -instance, +introduces the set e1 into the lexical +scope of the expression e2. For instance, let as = { x = "foo"; y = "bar"; }; @@ -1235,7 +1234,7 @@ weakest binding). none Select attribute denoted by the attribute path - attrpath from attribute set + attrpath from set e. (An attribute path is a dot-separated list of attribute names.) If the attribute doesn’t exist, return def if @@ -1251,8 +1250,8 @@ weakest binding). e ? attrpath none - Test whether attribute set e - contains the attribute denoted by attrpath; + Test whether set e contains + the attribute denoted by attrpath; return true or false. @@ -1275,10 +1274,11 @@ weakest binding). e1 // e2 right - Return an attribute set consisting of the attributes in + Return a set consisting of the attributes in e1 and e2 (with the latter taking - precedence over the former in case of equally named attributes). + precedence over the former in case of equally named + attributes). e1 == @@ -1322,9 +1322,9 @@ weakest binding).
Derivations The most important built-in function is -derivation, which is used to describe a -single derivation (a build action). It takes as input an attribute -set, the attributes of which specify the inputs of the build. +derivation, which is used to describe a single +derivation (a build action). It takes as input a set, the attributes +of which specify the inputs of the build. diff --git a/src/libexpr/attr-path.cc b/src/libexpr/attr-path.cc index d834dcae7..737166435 100644 --- a/src/libexpr/attr-path.cc +++ b/src/libexpr/attr-path.cc @@ -35,15 +35,14 @@ Value * findAlongAttrPath(EvalState & state, const string & attrPath, v = vNew; state.forceValue(*v); - /* It should evaluate to either an attribute set or an - expression, according to what is specified in the - attrPath. */ + /* It should evaluate to either a set or an expression, + according to what is specified in the attrPath. */ if (apType == apAttr) { if (v->type != tAttrs) throw TypeError( - format("the expression selected by the selection path `%1%' should be an attribute set but is %2%") + format("the expression selected by the selection path `%1%' should be a set but is %2%") % curPath % showType(*v)); Bindings::iterator a = v->attrs->find(state.symbols.create(attr)); diff --git a/src/libexpr/eval-inline.hh b/src/libexpr/eval-inline.hh index 722273dda..ec0206eb0 100644 --- a/src/libexpr/eval-inline.hh +++ b/src/libexpr/eval-inline.hh @@ -45,7 +45,7 @@ inline void EvalState::forceAttrs(Value & v) { forceValue(v); if (v.type != tAttrs) - throwTypeError("value is %1% while an attribute set was expected", showType(v)); + throwTypeError("value is %1% while a set was expected", showType(v)); } diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 29b3e3c82..814c19efc 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -116,7 +116,7 @@ string showType(const Value & v) case tString: return "a string"; case tPath: return "a path"; case tNull: return "null"; - case tAttrs: return "an attribute set"; + case tAttrs: return "a set"; case tList: return "a list"; case tThunk: return "a thunk"; case tApp: return "a function application"; @@ -488,7 +488,7 @@ inline void EvalState::evalAttrs(Env & env, Expr * e, Value & v) { e->eval(*this, env, v); if (v.type != tAttrs) - throwTypeError("value is %1% while an attribute set was expected", showType(v)); + throwTypeError("value is %1% while a set was expected", showType(v)); } @@ -898,9 +898,8 @@ void ExprOpUpdate::eval(EvalState & state, Env & env, Value & v) state.mkAttrs(v, v1.attrs->size() + v2.attrs->size()); - /* Merge the attribute sets, preferring values from the second - set. Make sure to keep the resulting vector in sorted - order. */ + /* Merge the sets, preferring values from the second set. Make + sure to keep the resulting vector in sorted order. */ Bindings::iterator i = v1.attrs->begin(); Bindings::iterator j = v2.attrs->begin(); @@ -1125,8 +1124,7 @@ string EvalState::coerceToString(Value & v, PathSet & context, if (v.type == tAttrs) { Bindings::iterator i = v.attrs->find(sOutPath); - if (i == v.attrs->end()) - throwTypeError("cannot coerce an attribute set (except a derivation) to a string"); + if (i == v.attrs->end()) throwTypeError("cannot coerce a set to a string"); return coerceToString(*i->value, context, coerceMore, copyToStore); } @@ -1172,9 +1170,8 @@ bool EvalState::eqValues(Value & v1, Value & v2) forceValue(v2); /* !!! Hack to support some old broken code that relies on pointer - equality tests between attribute sets. (Specifically, - builderDefs calls uniqList on a list of attribute sets.) Will - remove this eventually. */ + equality tests between sets. (Specifically, builderDefs calls + uniqList on a list of sets.) Will remove this eventually. */ if (&v1 == &v2) return true; if (v1.type != v2.type) return false; @@ -1212,8 +1209,8 @@ bool EvalState::eqValues(Value & v1, Value & v2) return true; case tAttrs: { - /* If both attribute sets denote a derivation (type = - "derivation"), then compare their outPaths. */ + /* If both sets denote a derivation (type = "derivation"), + then compare their outPaths. */ if (isDerivation(v1) && isDerivation(v2)) { Bindings::iterator i = v1.attrs->find(sOutPath); Bindings::iterator j = v2.attrs->find(sOutPath); @@ -1263,7 +1260,7 @@ void EvalState::printStats() printMsg(v, format(" list concatenations: %1%") % nrListConcats); printMsg(v, format(" values allocated: %1% (%2% bytes)") % nrValues % (nrValues * sizeof(Value))); - printMsg(v, format(" attribute sets allocated: %1%") % nrAttrsets); + printMsg(v, format(" sets allocated: %1%") % nrAttrsets); printMsg(v, format(" right-biased unions: %1%") % nrOpUpdates); printMsg(v, format(" values copied in right-biased unions: %1%") % nrOpUpdateValuesCopied); printMsg(v, format(" symbols in symbol table: %1%") % symbols.size()); diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 8707182ed..b896137a6 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -19,8 +19,8 @@ class EvalState; struct Attr; -/* Attribute sets are represented as a vector of attributes, sorted by - symbol (i.e. pointer to the attribute name in the symbol table). */ +/* Sets are represented as a vector of attributes, sorted by symbol + (i.e. pointer to the attribute name in the symbol table). */ #if HAVE_BOEHMGC typedef std::vector > BindingsBase; #else diff --git a/src/libexpr/get-drvs.cc b/src/libexpr/get-drvs.cc index f1cbc0bab..f5d7c189c 100644 --- a/src/libexpr/get-drvs.cc +++ b/src/libexpr/get-drvs.cc @@ -41,7 +41,7 @@ DrvInfo::Outputs DrvInfo::queryOutputs(EvalState & state) /* For each output... */ for (unsigned int j = 0; j < i->value->list.length; ++j) { - /* Evaluate the corresponding attribute set. */ + /* Evaluate the corresponding set. */ string name = state.forceStringNoCtx(*i->value->list.elems[j]); Bindings::iterator out = attrs->find(state.symbols.create(name)); if (out == attrs->end()) continue; // FIXME: throw error? @@ -119,11 +119,10 @@ void DrvInfo::setMetaInfo(const MetaInfo & meta) typedef set Done; -/* Evaluate value `v'. If it evaluates to an attribute set of type - `derivation', then put information about it in `drvs' (unless it's - already in `doneExprs'). The result boolean indicates whether it - makes sense for the caller to recursively search for derivations in - `v'. */ +/* Evaluate value `v'. If it evaluates to a set of type `derivation', + then put information about it in `drvs' (unless it's already in + `doneExprs'). The result boolean indicates whether it makes sense + for the caller to recursively search for derivations in `v'. */ static bool getDerivation(EvalState & state, Value & v, const string & attrPath, DrvInfos & drvs, Done & done, bool ignoreAssertionFailures) @@ -132,8 +131,8 @@ static bool getDerivation(EvalState & state, Value & v, state.forceValue(v); if (!state.isDerivation(v)) return true; - /* Remove spurious duplicates (e.g., an attribute set like - `rec { x = derivation {...}; y = x;}'. */ + /* Remove spurious duplicates (e.g., a set like `rec { x = + derivation {...}; y = x;}'. */ if (done.find(v.attrs) != done.end()) return false; done.insert(v.attrs); @@ -218,10 +217,9 @@ static void getDerivations(EvalState & state, Value & vIn, if (combineChannels) getDerivations(state, v2, pathPrefix2, autoArgs, drvs, done, ignoreAssertionFailures); else if (getDerivation(state, v2, pathPrefix2, drvs, done, ignoreAssertionFailures)) { - /* If the value of this attribute is itself an - attribute set, should we recurse into it? => Only - if it has a `recurseForDerivations = true' - attribute. */ + /* If the value of this attribute is itself a set, + should we recurse into it? => Only if it has a + `recurseForDerivations = true' attribute. */ if (v2.type == tAttrs) { Bindings::iterator j = v2.attrs->find(state.symbols.create("recurseForDerivations")); if (j != v2.attrs->end() && state.forceBool(*j->value)) diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh index 2178c016e..d5d7a0233 100644 --- a/src/libexpr/nixexpr.hh +++ b/src/libexpr/nixexpr.hh @@ -123,8 +123,8 @@ struct ExprVar : Expr levels up from the current environment and getting the `displ'th value in that environment. In the latter case, the value is obtained by getting the attribute named `name' from - the attribute set stored in the environment that is `level' - levels up from the current one.*/ + the set stored in the environment that is `level' levels up + from the current one.*/ unsigned int level; unsigned int displ; diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index badff1ca3..cfd669d26 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -103,7 +103,7 @@ static void prim_typeOf(EvalState & state, Value * * args, Value & v) case tString: t = "string"; break; case tPath: t = "path"; break; case tNull: t = "null"; break; - case tAttrs: t = "attrs"; break; + case tAttrs: t = "set"; break; case tList: t = "list"; break; case tLambda: case tPrimOp: @@ -729,12 +729,12 @@ static void prim_filterSource(EvalState & state, Value * * args, Value & v) /************************************************************* - * Attribute sets + * Sets *************************************************************/ -/* Return the names of the attributes in an attribute set as a sorted - list of strings. */ +/* Return the names of the attributes in a set as a sorted list of + strings. */ static void prim_attrNames(EvalState & state, Value * * args, Value & v) { state.forceAttrs(*args[0]); @@ -776,7 +776,7 @@ static void prim_hasAttr(EvalState & state, Value * * args, Value & v) } -/* Determine whether the argument is an attribute set. */ +/* Determine whether the argument is a set. */ static void prim_isAttrs(EvalState & state, Value * * args, Value & v) { state.forceValue(*args[0]); @@ -807,10 +807,10 @@ static void prim_removeAttrs(EvalState & state, Value * * args, Value & v) } -/* Builds an attribute set from a list specifying (name, value) - pairs. To be precise, a list [{name = "name1"; value = value1;} - ... {name = "nameN"; value = valueN;}] is transformed to {name1 = - value1; ... nameN = valueN;}. */ +/* Builds a set from a list specifying (name, value) pairs. To be + precise, a list [{name = "name1"; value = value1;} ... {name = + "nameN"; value = valueN;}] is transformed to {name1 = value1; + ... nameN = valueN;}. */ static void prim_listToAttrs(EvalState & state, Value * * args, Value & v) { state.forceList(*args[0]); @@ -844,9 +844,9 @@ static void prim_listToAttrs(EvalState & state, Value * * args, Value & v) } -/* Return the right-biased intersection of two attribute sets as1 and - as2, i.e. a set that contains every attribute from as2 that is also - a member of as1. */ +/* Return the right-biased intersection of two sets as1 and as2, + i.e. a set that contains every attribute from as2 that is also a + member of as1. */ static void prim_intersectAttrs(EvalState & state, Value * * args, Value & v) { state.forceAttrs(*args[0]); @@ -1240,7 +1240,7 @@ void EvalState::createBaseEnv() addPrimOp("__toFile", 2, prim_toFile); addPrimOp("__filterSource", 2, prim_filterSource); - // Attribute sets + // Sets addPrimOp("__attrNames", 1, prim_attrNames); addPrimOp("__getAttr", 2, prim_getAttr); addPrimOp("__hasAttr", 2, prim_hasAttr); @@ -1290,8 +1290,8 @@ void EvalState::createBaseEnv() evalFile(path, v); addConstant("derivation", v); - /* Now that we've added all primops, sort the `builtins' attribute - set, because attribute lookups expect it to be sorted. */ + /* Now that we've added all primops, sort the `builtins' set, + because attribute lookups expect it to be sorted. */ baseEnv.values[0]->attrs->sort(); } diff --git a/src/libexpr/symbol-table.hh b/src/libexpr/symbol-table.hh index 9129f0f46..08e31d496 100644 --- a/src/libexpr/symbol-table.hh +++ b/src/libexpr/symbol-table.hh @@ -13,11 +13,10 @@ namespace nix { /* Symbol table used by the parser and evaluator to represent and look - up identifiers and attribute sets efficiently. - SymbolTable::create() converts a string into a symbol. Symbols - have the property that they can be compared efficiently (using a - pointer equality test), because the symbol table stores only one - copy of each string. */ + up identifiers and attributes efficiently. SymbolTable::create() + converts a string into a symbol. Symbols have the property that + they can be compared efficiently (using a pointer equality test), + because the symbol table stores only one copy of each string. */ class Symbol { diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc index f0789a8c0..c30c88092 100644 --- a/src/nix-env/nix-env.cc +++ b/src/nix-env/nix-env.cc @@ -159,11 +159,11 @@ static void loadSourceExpr(EvalState & state, const Path & path, Value & v) } /* The path is a directory. Put the Nix expressions in the - directory in an attribute set, with the file name of each - expression as the attribute name. Recurse into subdirectories - (but keep the attribute set flat, not nested, to make it easier - for a user to have a ~/.nix-defexpr directory that includes - some system-wide directory). */ + directory in a set, with the file name of each expression as + the attribute name. Recurse into subdirectories (but keep the + set flat, not nested, to make it easier for a user to have a + ~/.nix-defexpr directory that includes some system-wide + directory). */ if (S_ISDIR(st.st_mode)) { state.mkAttrs(v, 16); state.mkList(*state.allocAttr(v, state.symbols.create("_combineChannels")), 0); diff --git a/tests/lang/eval-okay-types.exp b/tests/lang/eval-okay-types.exp index 0287a32b1..7a1f2cc17 100644 --- a/tests/lang/eval-okay-types.exp +++ b/tests/lang/eval-okay-types.exp @@ -1 +1 @@ -[ true false true false true false true false true false "int" "bool" "string" "null" "attrs" "list" "lambda" "lambda" "lambda" "lambda" ] +[ true false true false true false true false true false "int" "bool" "string" "null" "set" "list" "lambda" "lambda" "lambda" "lambda" ]