From 9279174dde3e1a450e63e866d2683352dd8238d3 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 14 Aug 2008 14:00:44 +0000 Subject: * Added an experimental feature suggested by Andres: ellipses ("...") in attribute set pattern matches. This allows defining a function that takes *at least* the listed attributes, while ignoring additional attributes. For instance, {stdenv, fetchurl, fuse, ...}: stdenv.mkDerivation { ... }; defines a function that requires an attribute set that contains the specified attributes but ignores others. The main advantage is that we can then write in all-packages.nix aefs = import ../bla/aefs pkgs; instead of aefs = import ../bla/aefs { inherit stdenv fetchurl fuse; }; This saves a lot of typing (not to mention not having to update all-packages.nix with purely mechanical changes). It saves as much typing as the "args: with args;" style, but has the advantage that the function arguments are properly declared (not implicit in what the body of the "with" uses). --- tests/lang/eval-okay-patterns.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests/lang/eval-okay-patterns.nix') diff --git a/tests/lang/eval-okay-patterns.nix b/tests/lang/eval-okay-patterns.nix index bcb9f3842e47..c233c406c766 100644 --- a/tests/lang/eval-okay-patterns.nix +++ b/tests/lang/eval-okay-patterns.nix @@ -8,9 +8,12 @@ let i = args@args2: args.x + args2.y; + j = {x, y, z, ...}: x + y + z; + in f {x = "a"; y = "b"; z = "c";} + g {x = "x"; y = "y"; z = "z";} + h {x = "D";} + h {x = "D"; y = "E"; z = "F";} + - i {x = "g"; y = "h";} + i {x = "g"; y = "h";} + + j {x = "i"; y = "j"; z = "k"; bla = "bla"; foo = "bar";} -- cgit 1.4.1