From 8ce96becf0ad7b41a272c4b30c36b56c517a2206 Mon Sep 17 00:00:00 2001 From: Joachim Schiele Date: Tue, 7 Jul 2015 02:09:50 +0200 Subject: extended args@ explanation --- doc/manual/expressions/language-constructs.xml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'doc/manual/expressions') diff --git a/doc/manual/expressions/language-constructs.xml b/doc/manual/expressions/language-constructs.xml index 74809bb412d3..e438e4b20a1c 100644 --- a/doc/manual/expressions/language-constructs.xml +++ b/doc/manual/expressions/language-constructs.xml @@ -177,13 +177,19 @@ map (concat "foo") [ "bar" "bla" "abc" ] An @-pattern provides a means of referring to the whole value being matched: - -args@{ x, y, z, ... }: z + y + x + args.a + args@{ x, y, z, ... }: z + y + x + args.a + +but can also be written as: + + { x, y, z, ... } @ args: z + y + x + args.a Here args is bound to the entire argument, which is further matched against the pattern { x, y, z, - ... }. - + ... }. This @-pattern makes mainly sense with an + ellipsis(...) as you can now access attribute names as + a, using args.a, which was given as an + additional attribute to the function. + -- cgit 1.4.1