Skip to content
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

Merged
merged 1 commit into from
Feb 6, 2024
Merged

Conversation

piegamesde
Copy link
Member

  • 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


#### Non-chainable operators

Operators which always return a truth value like `==` and `<` are non-chainable.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

@@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Comment on lines +671 to +702
some complicated calculation {
# arguments
} == other stuff {
# which may be multiline
}
Copy link
Member

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.

Copy link
Member Author

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

- 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 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.

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.
Copy link
Member

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.

Copy link
Member

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
  ];

Copy link
Member Author

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
@infinisil infinisil merged commit 6b430d7 into nix-rfc-101:master Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants