Skip to content

Add named ellipsis#5590

Draft
Synthetica9 wants to merge 2 commits intoNixOS:masterfrom
Synthetica9:named-ellipsis
Draft

Add named ellipsis#5590
Synthetica9 wants to merge 2 commits intoNixOS:masterfrom
Synthetica9:named-ellipsis

Conversation

@Synthetica9
Copy link
Member

@Synthetica9 Synthetica9 commented Nov 17, 2021

This PR adds a new language feature: named ellipsis.

nix-repl> ({ x, ... @ y } : y)  { x = 1; a = 1; }
{ a = 1; }

Often, we see the following pattern:

{ foo, bar, ... } @ args:
  let
    strippedArgs = builtins.removeAttrs args [ "foo" "bar" ];
  in
    ...

This is error-prone and repeats all the formal arguments. With this PR, this can be replaced with:

{ foo, bar, ... @ strippedArgs }:
  ...

TODO

  • Write an RFC to get this properly discussed in the community
  • Hide this behind a flag
  • Write tests
  • Write documentation

@domenkozar
Copy link
Member

NixOS/rfcs#58

@stale
Copy link

stale bot commented Jun 12, 2022

I marked this as stale due to inactivity. → More info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants