From ad09702fd421f40b1e7a93f95cca15b342db0104 Mon Sep 17 00:00:00 2001 From: Ryan Burns Date: Tue, 19 Oct 2021 19:37:14 -0700 Subject: [PATCH] Simplify desugared form Before: ``` [ inherit (attrs) a b c; ] := builtins.attrValues { inherit (attrs) a b c; } ``` After: ``` [ inherit (attrs) a b c; ] := [ attrs.a attrs.b attrs.c ]; ``` The previous desugaring has some potentially nice properties such as non-significant ordering and no-duplicate enforcement, but was ultimately deemed unintuitive and too surprising in practical use. --- rfcs/0110-inherit-as-list.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/rfcs/0110-inherit-as-list.md b/rfcs/0110-inherit-as-list.md index 0b07e32..dc06bc6 100644 --- a/rfcs/0110-inherit-as-list.md +++ b/rfcs/0110-inherit-as-list.md @@ -65,8 +65,8 @@ The proposed syntax is: These expressions are (respectively) syntactic sugar for: ```nix -builtins.attrValues { inherit (attrs) a b c; } -builtins.attrValues { inherit a b c; } +[ attrs.a attrs.b attrs.c ] +[ a b c ] ``` The `inherit` keyword is intentionally reused so as to not add any new @@ -112,17 +112,15 @@ buildInputs = [ ]; ``` -Sinc attributes inherit from the current scope with `{ inherit a b c; }`, -this RFC proposes a corresponding list-inherit syntax which also inherits -from the current scope. So if the order of the ordinary elements in the -previous list is not significant, one could rewrite the list as: +The order of the elements is preserved inside of and between inherits, +so the previous is exactly equivalent to ``` buildInputs = [ - inherit a b c; - inherit (pkgsFoo) d e f; - inherit g h i; - inherit (pkgsBar) j k l; + a b c + pkgsFoo.d pkgsFoo.e pkgsFoo.f + g h i + pkgsBar.j pkgsBar.k pkgsBar.l ]; ```