Refactor object.d: Move destroy and friends to new file, lifetime.d#2222
Refactor object.d: Move destroy and friends to new file, lifetime.d#2222JinShil wants to merge 1 commit intodlang:masterfrom JinShil:object_lifetime
destroy and friends to new file, lifetime.d#2222Conversation
|
Thanks for your pull request, @JinShil! 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#2222" |
src/lifetime.d
Outdated
| catch(Exception) assert(false); | ||
|
|
||
| assert(postblitRecurseOrder == order); | ||
| } No newline at end of file |
There was a problem hiding this comment.
Missing newline at end of file.
|
Be a bit careful here, on a PR a couple of months ago Andrei expressed his opinion of not doing the split because he was worried about the performance implications of it. |
|
What is the purpose of this sanitizing json test? |
|
+1 This makes searching for certain functions much easier. |
It's a wrapper around the json tests that replaces a few fields which are different depending on the host environment, build environment/OS. Have a look at https://github.com/dlang/dmd/blob/3a2d609093c0df1dc008577ad607963fc431fd39/test/tools/sanitize_json.d#L176 It already does filter druntime and phobos out: if(moduleName.startsWith("std.", "core.", "etc.") || moduleName == "object")It's just that you introduce a new top-level moduleName that isn't reserved yet. |
src/lifetime.d
Outdated
| /** | ||
| * Contains utilities for managing lifetimes. | ||
| * | ||
| * Copyright: Copyright Digital Mars 2000 - 2018. |
There was a problem hiding this comment.
You can safely set the copyright to the D Language Foundation.
DMD is specifically hard-coded to look for object.d, so that will require an update to DMD as well. Also, I'd like to remove the object moniker as object.d really has very little to do with I think I can move lifetime.d to something like internal/lifetime.d for now until we make the necessary DMD changes. We can reshuffle file locations at that time. |
Please help me understand. How would having these declarations in a separate file and publicly imported negatively affect performance? |
He was worried about the extra time needed to open these five more files. We just need to prove that there's no such penalty or that it's not measurable compared to all the other things DMD does. |
You would need to go for |
|
I went with |
|
I went back to lifetime.d being a sibling of object.d. I'm going to modify the sanitize json test to make it work. |
|
I'm not sure that's a good idea. This will prevent anyone from using |
|
My motivation is to model it after other well-designed packages. The one that comes to mind is |
|
I agree that renaming object.d to object/package.d is a good way to go forward, I'm just worried that we end up with this intermediate step in the next release. |
|
@wilzbach is right, Another thing to think about -- the splitting of this module does not have the same requirements as other package split-ups such as std.algorithm. Every D program imports this module, so if we make And given that, I don't think it's very important to put these as siblings or a package with |
Actually I was just planning on renaming object.d to package.d in place without moving it to an object subdirectory. object is really a misnomer at this point and when we implicitly
I would have been ok with that, but it ended up causing strange issues. Take a look at the test failures in https://auto-tester.puremagic.com/show-run.ghtml?projectid=1&runid=3212929&isPull=true See source code for that test at https://github.com/dlang/dmd/blob/4b8555e9c9b7a840549c68c39eef26782cfbb23f/test/compilable/test8937.d#L26-L28 if (true)
static import core.stdc.math;
static assert(!__traits(compiles, core.stdc.math.cos(0))); // failsSo, if I go that route, I'm going to be required to make changes to the compiler. |
The first failure has to do with the fact that object is importing The second issue, that is more interesting. I think this is not just a quirk, but an actual bug in the compiler. You're not importing core.stdc.math but object has imported core.something.else. That shouldn't affect the imports. I'd say we need to fix that bug regardless of whether we split object.d into pieces. The question is, where does it come from? But I'd consider having to fix bugs in the compiler preferable to adding/changing features in the compiler. We may have to fix the bugs in either case. |
|
https://issues.dlang.org/show_bug.cgi?id=19014 is currently blocking progress on this. Any help fixing that would be greatly appreciated. |
object.d has become a dumping ground for anything and everything druntime, and is too unwieldy. For evidence, see the diff at https://github.com/dlang/druntime/pull/2194/files -- it's out of control, and I'm tired of it.
This is a refactoring based on suggestions by @ZombineDev at #2194 (comment)
As suggested by @ZombineDev, my plan is to move related implementations into their own files and publicly import them in object.d. Ideas are currently:
lifetime.d -
destroyand friendsarray.d - dynamic array support
typeinfo.d - all the
TypeInfoclasses and maybe evenModuleInfoassociativeArray.d - associative array support
comparison.d -
__cmpand__equals... { you get the idea }
Eventually it would be nice to change object.d to package.d, but I'm getting ahead of myself. For now, let's start with lifetime.d...that's this PR.
There may also be other benefits besides making druntime maintenance more manageable, such as encapsulation. As we submit more PRs to refactor object.d, DMD will also need some changes, but I hope we can visit those when their time comes.
I'm not sure how this will affect the published documentation. I guess we'll soon find out when DAutoTest runs.