Skip to content

Commit

Permalink
Merge pull request NixOS#576 from qknight/args_explanation
Browse files Browse the repository at this point in the history
extended args@ explanation
  • Loading branch information
domenkozar committed May 30, 2016
2 parents f7be732 + 6766041 commit 5339ae4
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions doc/manual/expressions/language-constructs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,19 @@ map (concat "foo") [ "bar" "bla" "abc" ]</programlisting>
<listitem><para>An <literal>@</literal>-pattern provides a means of referring
to the whole value being matched:

<programlisting>
args@{ x, y, z, ... }: z + y + x + args.a</programlisting>
<programlisting> args@{ x, y, z, ... }: z + y + x + args.a</programlisting>

but can also be written as:

<programlisting> { x, y, z, ... } @ args: z + y + x + args.a</programlisting>

Here <varname>args</varname> is bound to the entire argument, which
is further matched against the pattern <literal>{ x, y, z,
... }</literal>.</para></listitem>

... }</literal>. <literal>@</literal>-pattern makes mainly sense with an
ellipsis(<literal>...</literal>) as you can access attribute names as
<literal>a</literal>, using <literal>args.a</literal>, which was given as an
additional attribute to the function.
</para></listitem>

</itemizedlist>

Expand Down Expand Up @@ -359,4 +365,4 @@ character, or inline/multi-line, enclosed within <literal>/*
</simplesect>


</section>
</section>

0 comments on commit 5339ae4

Please sign in to comment.