* Documented the primops.
This commit is contained in:
parent
b0c9baf1b5
commit
87bf541f23
2 changed files with 102 additions and 3 deletions
|
@ -4,9 +4,6 @@
|
||||||
<sect1>
|
<sect1>
|
||||||
<title>Grammar</title>
|
<title>Grammar</title>
|
||||||
|
|
||||||
<para>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<productionset>
|
<productionset>
|
||||||
<title>Expressions</title>
|
<title>Expressions</title>
|
||||||
|
|
||||||
|
@ -97,6 +94,8 @@
|
||||||
<nonterminal def="#nix.path" /> |
|
<nonterminal def="#nix.path" /> |
|
||||||
<nonterminal def="#nix.uri" />
|
<nonterminal def="#nix.uri" />
|
||||||
<sbr />|
|
<sbr />|
|
||||||
|
'true' | 'false' | 'null'
|
||||||
|
<sbr />|
|
||||||
'(' <nonterminal def="#nix.expr" /> ')'
|
'(' <nonterminal def="#nix.expr" /> ')'
|
||||||
<sbr />|
|
<sbr />|
|
||||||
'{' <nonterminal def="#nix.bind" />* '}'
|
'{' <nonterminal def="#nix.bind" />* '}'
|
||||||
|
@ -180,4 +179,99 @@
|
||||||
|
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<sect1>
|
||||||
|
<title>Semantics</title>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<sect2>
|
||||||
|
<title>Built-in functions</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The Nix language provides the following built-in function
|
||||||
|
(<quote>primops</quote>):
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><function>import</function>
|
||||||
|
<replaceable>e</replaceable></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Evaluates the expression <replaceable>e</replaceable>,
|
||||||
|
which must yield a path value. The Nix expression
|
||||||
|
stored at this path in the file system is then read,
|
||||||
|
parsed, and evaluated. Returns the result of the
|
||||||
|
evaluation of the Nix expression just read.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Example: <literal>import ./foo.nix</literal> evaluates
|
||||||
|
the expression stored in <filename>foo.nix</filename>
|
||||||
|
(in the directory containing the expression in which the
|
||||||
|
<function>import</function> occurs).
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><function>derivation</function>
|
||||||
|
<replaceable>e</replaceable></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Evaluates the expression <replaceable>e</replaceable>,
|
||||||
|
which must yield an attribute set. [...]
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><function>baseNameOf</function>
|
||||||
|
<replaceable>e</replaceable></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Evaluates the expression <replaceable>e</replaceable>,
|
||||||
|
which must yield a string value, and returns a string
|
||||||
|
representing its <emphasis>base name</emphasis>. This
|
||||||
|
is the substring following the last path separator
|
||||||
|
(<literal>/</literal>).
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Example: <literal>baseNameOf "/foo/bar"</literal>
|
||||||
|
returns <literal>"bar"</literal>, and
|
||||||
|
<literal>baseNameOf "/foo/bar/"</literal> returns
|
||||||
|
<literal>""</literal>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><function>toString</function>
|
||||||
|
<replaceable>e</replaceable></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Evaluates the expression <replaceable>e</replaceable>
|
||||||
|
and coerces it into a string, if possible. Only
|
||||||
|
strings, paths, and URIs can be so coerced.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Example: <literal>toString
|
||||||
|
http://www.cs.uu.nl/</literal> returns
|
||||||
|
<literal>"http://www.cs.uu.nl/"</literal>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
</variablelist>
|
||||||
|
|
||||||
|
</sect2>
|
||||||
|
|
||||||
|
</sect1>
|
||||||
|
|
||||||
|
|
||||||
</chapter>
|
</chapter>
|
|
@ -218,4 +218,9 @@ div.epigraph
|
||||||
{
|
{
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.productionset table.productionset
|
||||||
|
{
|
||||||
|
font-family: monospace;
|
||||||
}
|
}
|
Loading…
Reference in a new issue