-
Notifications
You must be signed in to change notification settings - Fork 0
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
Working towards finalization #16
Conversation
rfcs/0166-nix-formatting.md
Outdated
|
||
#### Non-chainable operators | ||
|
||
Operators which always return a truth value like `==` and `<` are non-chainable. |
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.
Operators which always return a truth value like `==` and `<` are non-chainable. | |
[Operators](https://nixos.org/manual/nix/stable/language/operators.html#operators) with no associativity are non-chainable. |
rfcs/0166-nix-formatting.md
Outdated
@@ -620,11 +656,37 @@ null | |||
|
|||
### Operators | |||
|
|||
Chained binary associative [operators](https://nixos.org/manual/nix/stable/language/operators.html#operators) (except [function application](#function-application)) with the same or monotonically decreasing precedence must be treated together as a single operator chain. | |||
Function application is not treated as an "operator" in the sense of this section, see [function application](#function-application) instead. |
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.
Function application is not treated as an "operator" in the sense of this section, see [function application](#function-application) instead. | |
From the [list of operators](https://nixos.org/manual/nix/stable/language/operators.html#operators), this section focuses on binary operators. | |
Function application is not treated as an "operator" in the sense of this section, see [function application](#function-application) instead. |
some complicated calculation { | ||
# arguments | ||
} == other stuff { | ||
# which may be multiline | ||
} |
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.
This feels like an obscure edge case that we shouldn't handle this specially. I expect it to be very rare to have multi-line expressions on both sides.
I think it would be fine to force the normal binary operator case instead, and limit this special case only to when one side fits on one line.
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.
This special case dates from a time where the infrastructure for "if one side fits on a single line" did not exist, so having it also for both sides expanded was just a (sufficiently rare) false positive. I can try to narrow it down in the code
rfcs/0166-nix-formatting.md
Outdated
- Otherwise it must start on a new line. | ||
- `with` expressions of absorbable terms are handled like absorbable terms themselves. | ||
- This means that in any situation where a term would get absorbed, a `with` of an absorbable term should get absorbed as well. | ||
- Conversely, when a `with` cannot get absorbed, its but shouldn't be either. |
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.
- Conversely, when a `with` cannot get absorbed, its but shouldn't be either. | |
- Conversely, when a `with` cannot get absorbed, its body shouldn't be either. |
rfcs/0166-nix-formatting.md
Outdated
and `with attrs; …` is parenthesised or to the right side of a binding (e.g. `(with; [ …` or `foo = with; [ …`), | ||
then `with` must start on the same line. | ||
- Otherwise it must start on a new line. | ||
- `with` expressions of absorbable terms are handled like absorbable terms themselves. |
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 was pretty clear from the last meeting that it's not just terms that should be treated as absorbable.
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.
And this contradicts the example: If { ... }
is absorbable, then with bar; { ... }
is also absorbable according to this sentence, which means it should be this:
foo = with foo; with bar; [
# multiline
baz
];
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 was pretty clear from the last meeting that it's not just terms that should be treated as absorbable.
Within the context of with
statements, absorbing anything else does not make much sense.
Within the context of general expressions, the property "absorbable" does not give much value to define, as it is heavily context dependent. (See below)
And this contradicts the example
No it is not, since the body of with foo;
is not an absorbable term. The relevant question at hand here is not "is with bar;
absorbable?", but instead "will with bar;
be absorbed?". Because the first question would only look at the expression itself and its content. But the second question actually correctly represents the fact that the actual behavior is also dependent on the outer context.
If you want, you can see it as "being absorbable is a necessary condition for absorbtion", however this usually is such a weak condition for anything other than absorbable terms that it does not help that much to formally define "absorbable expression".
- Defined absorption and absorbable terms - Adapted the existing RFC text to make use of these definitions, resulting in simplications of the text in many cases. - Updated `with` section to match the implementation - Updated the function declaration section to match the implementation - Sometimes, the function body may get absorbed - This used to be a special case scoped to bindings only, so it got removed there - Updated the operators section to match the implementation - Specify the format of non-chainable operators (somehow those got lost in the past) - Reworked bindings section. It should now be clear and specific enough. - Minor wording fixes
8f06f61
to
1546db9
Compare
with
section to match the implementation