-
-
Notifications
You must be signed in to change notification settings - Fork 411
Move emplace to druntime for symmetry with destroy.
#2398
Conversation
|
Thanks for your pull request and interest in making D better, @TurkeyMan! 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 fetch digger
dub run digger -- build "master + druntime#2398" |
|
I don't think this is a good idea. There's already way too much stuff in object.d. |
I tried to do something about that in #2222, but then I ran into https://issues.dlang.org/show_bug.cgi?id=19014 Maybe that can move forward now since time has passed. |
007aae6 to
ef2bddd
Compare
It's just one function, and it's a direct missing complement to one of the most important functions in By your argument,
|
|
@JinShil If you wanna move |
ef2bddd to
7b1cd79
Compare
|
I'm not going to do anything. I just wanted to point out that there is a way forward to reduce the size of object.d. I have no opinion on whether this should be merged or not, and I am no longer working on the team. |
|
Okay. Well while I sympathise that object.d is kinda big, and it could be smaller, I find that issue microscopic compared to the fact that |
7b1cd79 to
bec59b4
Compare
|
Would it be a reasonable compromise to put The truth is, D supplies 2 forms of construction -- one on the stack, and one on the heap. The reason I agree it would be nice to have |
|
I have no issue with it being in another module, but I do think it should be in the same place as |
I'd argue that the language supplies no forms of construction, only allocation (with implicit construction). The language has no construction syntax (ie, C++ placement new), and so we write it awkwardly in a library ( You can't write a whole lot of tooling and container objects without being able to construct. |
In any case, |
|
Which is exactly why I put emplace here ;) |
I believe |
|
moving In other words, it would be perfectly acceptable to have emplace live in hypothetical
If we were also adding |
Understood, but that's not the motivation for moving it. object.d has too much stuff in it which causes problems when creating pull requests against it; see the diff for #2194. All that PR did was moving some implementations behind a |
|
The thing that's bullshit about this whole community is that people will readily complain and bikeshed when someone tries to get something done, but they wouldn't do it themselves. This is holding me up. Let me fix it, or fix it yourself... but don't be a barrier to both. |
|
In my attempt with #2222 I had to fix 2 other bugs: dlang/dmd#8519 and dlang/dmd#8519 and eventually got stalled on https://issues.dlang.org/show_bug.cgi?id=19014. I didn't get any shortcuts; I did what needed to be done and even made time to help you, @TurkeyMan , with a bug I couldn't care less about: dlang/dmd#8631 and a number of other bugs for other people. When working on D (or any other software for that matter) this is how it often goes: https://www.youtube.com/watch?v=AbSehcT19u0 The size of object.d is a legitimate technical concern, yet I already admitted that it is a distraction from the merits of this PR. This PR could be merged regardless (I defer to others' judgment on that), but someone, someday will eventually need to deal the object.d monstrosity and ignoring it now (actually adding to it) is just passing the buck. |
|
I appreciate you working through those issues. Is destroy definitely going to move? I can put emplace where it will move to, but it needs to move if so... They should be kept together, and if it's not actually gonna move, then one more function next to destroy won't change the existing undesirable situation in any significant way. |
I don't know. Let's wait to see what happens with the PR. Perhaps my work and our concerns were all for naught. There are competing opinions here, and I can't predict what wins. I have no opinion about whether |
One could argue that the opposite of |
This is NOT bikeshedding. Once you add a symbol to object.d, it has to stay there forever (or at least always be imported automatically). If you put it in a different module inside druntime, then it's opt-in to import. This is a huge difference. Think of it this way, if you import If it's determined that it would be better suited in object.d, we can move it there later. If we put it in object.d now, and decide later it shouldn't be there, the decision cannot be reversed. I've said my piece. I'm not the final decision maker anyway, but it's frustrating not to be able to bring up technical problems with a PR without getting yelled at. |
You could argue, but I think you'd fail. |
Can we just move it in |
|
Yes, please! Let's use either |
94c303c to
ebe9aae
Compare
|
Moved to |
b709f86 to
4e520aa
Compare
jacob-carlborg
left a comment
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.
- I don't see any tests for C++ and Objective-C classes/interfaces
- Are there any tests for CTFE?
| address. If `T` is a class, initializes the class reference to null. | ||
| Returns: A pointer to the newly constructed object (which is the same | ||
| as `chunk`). | ||
| */ |
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.
- Missing
Paramssection - Please add a blank line between the sections
| Returns: A pointer to the newly constructed object (which is the same | ||
| as `chunk`). | ||
| */ | ||
| T* emplace(T, Args...)(T* chunk, auto ref Args args) |
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.
- Missing
Paramssection - Please add a blank line between the sections
| This function is `@safe` if the corresponding constructor of `T` is `@safe`. | ||
| Returns: The newly constructed object. | ||
| */ | ||
| T emplace(T, Args...)(T chunk, auto ref Args args) |
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.
- Missing
Paramssection - Please add a blank line between the sections
| /// | ||
| @safe unittest | ||
| { | ||
| () @safe { |
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 is this necessary when the whole unit test block is @safe?
| This function can be `@trusted` if the corresponding constructor of `T` is `@safe`. | ||
| Returns: The newly constructed object. | ||
| */ | ||
| T emplace(T, Args...)(void[] chunk, auto ref Args args) |
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.
- Missing
Paramssection - Please add a blank line between the sections
| `T` is `@safe`. | ||
| Returns: A pointer to the newly constructed object. | ||
| */ | ||
| T* emplace(T, Args...)(void[] chunk, auto ref Args args) |
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.
- Missing
Paramssection - Please add a blank line between the sections
| I i = void; | ||
| emplace(&i); | ||
| assert(i is null); | ||
| } |
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.
Should there be a test that verifies that the constructor has been called?
|
@thewilsonator Just an FYI, I think it's considered extremely poor form to rebrand someone's git commit metadata when you amend. I've seen this occur on a few other PR's, I'd suggest that when you amend someone's PR's, take extra care not to erase the original authors attribution and commit metadata. |
4e520aa to
5ceab47
Compare
emplace to object.d for symmetry with destroy.emplace to druntime for symmetry with destroy.
|
@jacob-carlborg I don't want to change anything about the implementation in this PR. It's a perfect clone of phobos to the extent we know it works. If we tidy the things you say, I'd like to see that in a separate PR where it's not conflated with moving it to druntime. |
Fine. |
|
|
|
I see what's happened, this PR was actually the original patch to introduce those traits, but nick extracted that code into a separate PR and merged, but reformatted it in the process. When I rebased, my (original) formatting changes were the only differences that remained. |
|
The idea here was to have ZERO delta from the phobos code, and that's what's in this patch ;) |
As discussed previously, this PR should only copy the phobos implementation. Any improvements should come after this PR is merged.
Sorry, my editor occasionally does funny things with formatting. |
|
Thx! Sadly, I just noticed that it doesn't end here :( |
|
I kinda feel like |
|
Sure, its as good a place as any I suppose. |
|
+1 for |
destroy()is in object.d, which makes sense, because one of the most primitive operations you can perform is to cause destruction of an object.Strangely, we can't construct objects though... because
emplace()is in phobos, which isn't helpful for projects that don't link phobos. (it's huge, and it's notnothrow @nogc)I think
emplace()really needs to live right next todestroy(); it's a direct counterpart, so here it is.If this is accepted, we'll make phobos emplace alias this one moved here.