-
-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC 0058] Named Ellipses #58
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5fda3ff
Create 0057-named-ellipses.md
deliciouslytyped c4f6cc9
Update 0057-named-ellipses.md
deliciouslytyped 1b74fac
Update 0057-named-ellipses.md
deliciouslytyped c38f79a
Update 0057-named-ellipses.md
deliciouslytyped 23e5126
Update 0057-named-ellipses.md
deliciouslytyped f1acf12
Update 0057-named-ellipses.md
deliciouslytyped bde88ba
Update 0057-named-ellipses.md
deliciouslytyped 776cb0f
accidentally interchanged some words
deliciouslytyped 966bce4
added todo
deliciouslytyped 3fe2733
Update rfcs/0057-named-ellipses.md
deliciouslytyped 30108be
Update rfcs/0057-named-ellipses.md
deliciouslytyped 8c4dd00
Update rfcs/0057-named-ellipses.md
deliciouslytyped 9044d4e
Update 0057-named-ellipses.md
deliciouslytyped ff5795a
Add shepherd team to metadata
lheckemann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
feature: Named Ellipses | ||
start-date: 2019-11-14 | ||
author: deliciouslytyped | ||
co-authors: none | ||
shepherd-team: Eelco Dolstra, Michael Raskin, jD91mZM2 | ||
shepherd-leader: Michael Raskin | ||
related-issues: | ||
Named Ellipses - https://github.com/NixOS/nix/issues/2998 | ||
--- | ||
|
||
# Summary | ||
[summary]: #summary | ||
|
||
It should be possible to bind a name to ellipses in a function definition like `{ a, ...@extra }: null`, and `{ a, extra@... }: null`. This makes intuitive sense, and could remove the need for a lot of uses of `removeAttrs` that really just want to refer to the contents of ellipses. | ||
|
||
Nixpkgs often gets commits like https://github.com/NixOS/nixpkgs/commit/a50653295df5e2565b4a6a316923f9e939f1945b with code that would be cleaner without the need for extra `removeAttrs`. | ||
|
||
# Detailed design | ||
[design]: #detailed-design | ||
|
||
The intent of this syntax is for `{...@args}:` to behave as consistent with `{...} @ args:` | ||
as practical. As both `args @ {…}` and `{…} @ args` forms happen in Nixpkgs, both would be supported for named ellipses, too. | ||
|
||
As `args @ {args}: ` is an error in Nix because of duplicate argument names, so should be `{extra, ...@extra}: `. As `(a @ { ... }: a) {a=1;}` returns `{a=1;}`, so should `({ a @ ... }: a) {a=1;}`. ``` | ||
|
||
TODO: consider what other languages like Haskell do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that you want to consider pattern matching libraries, too, not just function arguments. Some languages use notations that wouldn't fit well with the current use of |
||
|
||
# Drawbacks | ||
[drawbacks]: #drawbacks | ||
This increases the amount of syntax Nix has, thus creating some maintenance cost both for Nix itself, and for tools intended to work with Nix syntax (from highlighting to hnix) | ||
|
||
# Alternatives | ||
[alternatives]: #alternatives | ||
Not doing this would not have any major impact besides not making Nix and nixpkgs nicer to use. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be useful to have an example of how people are currently using
removeAttrs
somehwere in the RFC, for comparison.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's what I meant. I'll add something when I have some spare brain for it, unless someone else wants to give it a shot.