doc: document lib.makeOverridable
This commit is contained in:
parent
01ce5ce050
commit
e06f494a81
|
@ -85,4 +85,36 @@ in ...</programlisting>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section xml:id="sec-lib-makeOverridable">
|
||||||
|
<title>lib.makeOverridable</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The function <varname>lib.makeOverridable</varname> is used make the result
|
||||||
|
of a function easily customizable. This utility only makes sense for functions
|
||||||
|
that accept an argument set and return an attribute set.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Example usage:
|
||||||
|
|
||||||
|
<programlisting>f = { a, b }: { result = a+b; }
|
||||||
|
c = lib.makeOverridable f { a = 1; b = 2; }</programlisting>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The variable <varname>c</varname> is the value of the <varname>f</varname> function
|
||||||
|
applied with some default arguments. Hence the value of <varname>c.result</varname>
|
||||||
|
is <literal>3</literal>, in this example.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The variable <varname>c</varname> however also has some additional functions, like
|
||||||
|
<link linkend="sec-pkg-override">c.override</link> which can be used to
|
||||||
|
override the default arguments. In this example the value of
|
||||||
|
<varname>(c.override { a = 4; }).result</varname> is 6.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
</section>
|
||||||
|
|
||||||
</chapter>
|
</chapter>
|
||||||
|
|
Loading…
Reference in New Issue