-
-
Notifications
You must be signed in to change notification settings - Fork 700
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
Conversation
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 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 referencesYour 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 locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + phobos#9045" |
std/uni/package.d
Outdated
@@ -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 |
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.
Surely auto ref const
is more appropriate?
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.
Why? I feel indifferent about the two.
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.
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.
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'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.
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.
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.
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.
Makes sense, I changed it
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.
🤷♂️
2a32597
to
bea8d2d
Compare
As discussed in the last DLF monthly meeting,
auto ref
should be adjacent.