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

std.uni: Make auto ref adjacent #9045

Merged
merged 1 commit into from
Aug 14, 2024
Merged

Conversation

dkorpel
Copy link
Contributor

@dkorpel dkorpel commented Aug 14, 2024

As discussed in the last DLF monthly meeting, auto ref should be adjacent.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @dkorpel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + phobos#9045"

@@ -3349,7 +3349,7 @@ struct CowArray(SP=GcPolicy)
data[$-val.length-1 .. $-1] = val[];
}

bool opEquals()(auto const ref CowArray rhs)const
bool opEquals()(const auto ref CowArray rhs)const
Copy link
Contributor

Choose a reason for hiding this comment

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

Surely auto ref const is more appropriate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why? I feel indifferent about the two.

Copy link
Contributor

Choose a reason for hiding this comment

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

because this is valid syntax: auto ref const(CowArray) rhs, and this is not: const(auto ref CowArray) nhs.

But in particular, parens like that are required in many cases, for instance:

struct S {
  const(T) method();
  const T method(); // not the same; this is a synonym for `T method() const`
}

Since using const(T) syntax is required for disambiguation in various circumstances, my feeling is that it's much less confusing and certainly more expected to find the const immediately before the thing that is const.
If it were up to me, I would even write it in the language spec.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a conceptual flow thing:
const auto ref T goes: type stuff (const) -> storage class stuff (auto ref) -> type stuff (T)
auto ref const T goes: storage class stuff (auto ref) -> type stuff (const T)
It's crude to interleave type stuff and storage class stuff in an arbitrary way.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since it's invalid to put storage class stuff on the end (actual type must be on the end), then I would mandate that storage class stuff should go at the start, not randomly in the middle somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, I changed it

Copy link
Contributor

Choose a reason for hiding this comment

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

🤷‍♂️

@dlang-bot dlang-bot merged commit bbb1566 into dlang:master Aug 14, 2024
10 checks passed
@dkorpel dkorpel deleted the auto-ref-adjacent branch August 14, 2024 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants