Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive

Conversation

@JinShil
Copy link
Contributor

@JinShil JinShil commented Dec 9, 2018

Reboot of #2222 in an attempt to help with #2398

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @JinShil! 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 annotated coverage diff directly on GitHub with CodeCov's browser extension
  • 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 fetch digger
dub run digger -- build "master + druntime#2399"

@thewilsonator
Copy link
Contributor

/var/lib/buildkite-agent/builds/buildkite-agent-04-1/dlang/druntime/build/distribution/bin/../imports/object_/lifetime.d(446): Deprecation: `object.isnan` is not visible from module `lifetime`
--
  | /var/lib/buildkite-agent/builds/buildkite-agent-04-1/dlang/druntime/build/distribution/bin/../imports/object_/lifetime.d(446): Error: function `object.isnan` is not accessible from module `lifetime`

@JinShil
Copy link
Contributor Author

JinShil commented Dec 9, 2018

Thanks, @thewilsonator

@thewilsonator
Copy link
Contributor

No problems.

@JinShil
Copy link
Contributor Author

JinShil commented Dec 9, 2018

The auto-tester was failing, so I tried to modify some of the makefiles. Now circleci is failing. I don't know why. If someone has an idea, please let me know.

endif

# macro that returns the module name given the src path
moduleName=$(subst rt.invariant,invariant,$(subst object_,object,$(subst /,.,$(1))))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is a string replacement from a bygone era, so I removed it. But I'm not even sure if I did it correctly because I generally don't work with makefiles, and dread it every time I have to.

@JinShil
Copy link
Contributor Author

JinShil commented Dec 9, 2018

What is this all about, and why is it affecting this PR?

compilable/json.d(185): Deprecation: `extern(Pascal)` is deprecated. You might want to use `extern(Windows)` instead.

EDIT: Nevermind. I see it's actually complaining about the sanitized json diff. Looks like this needs a change to the DMD repository.

EDIT: This PR now needs dlang/dmd#9049

@JinShil
Copy link
Contributor Author

JinShil commented Dec 9, 2018

WARNING: This PR causes a huge change in the documentation; see DAutoTest, but I can't see the usual diffs to determine what the changes are. I browsed the documentation and couldn't find any issues, but that doesn't mean there aren't any.

EDIT: Looks like destroy is missing from object now: http://dtest.dlang.io/artifact/website-0f10794ab3a1dd660a6c9969e522088fb4f89147-17f397fbca460634f6544e1ba7bbafa0/web/phobos-prerelease/object.html
I'm not yet sure how to fix that.

@JinShil
Copy link
Contributor Author

JinShil commented Dec 9, 2018

I don't understand what's failing in DAutoTest. @CyberShadow could you take a quick look? Or @adamdruppe, is that your code?

EDIT: Nevermind. I think the real error was further down in the wall of output text. I think I figured it out.

@JinShil
Copy link
Contributor Author

JinShil commented Dec 9, 2018

Ok, this is looking good now. Please notice the changes in the documentation. There's a new object_ package in the left navigation and that's why there are so many changed files.

There was a concern in #2222 about this negatively affecting build times. I couldn't see any measurable difference when building phobos (at least with all the statistical noise). Reviewers are advised to independently verify.

@JinShil
Copy link
Contributor Author

JinShil commented Dec 9, 2018

If this is accepted, I'll do some of the others. I'm thinking...

object_/array.d - dynamic array support
object_/typeinfo.d - all the TypeInfo classes and maybe even ModuleInfo
object_/associativeArray.d - associative array support
object_/comparison.d - __cmp and __equals

* Contains utilities for managing lifetimes.
*
* This module is not intended to be imported or used directly. It is
* publicly imported by object.d, and should be accessed through there.
Copy link
Member

Choose a reason for hiding this comment

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

What does "should be accessed through there" mean? Would it be more accurate to say that the declarations in this module are automatically available in all D modules, like those in object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This module is not intended to be imported or used directly. It...

"It" refers to "This module".

It is publicly imported by object.d, and should be accessed through there.

"there" refers to "object.d"

This is natural English for me (using pronouns to refer to previously mentioned things). If you'd like me to change it, please send me copy-pastable text.

Copy link
Member

Choose a reason for hiding this comment

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

What I'm trying to say is that it might not be obvious to users that they don't have to import anything in order to use the symbols from that module. E.g. someone googles for "dlang destroy object", finds this page on dlang.org, sees that it's in a module, and tries importing it. Heck, at that point the user might not even know that even object doesn't need to be imported.

"accessed through there" also can be interpreted that something needs to be done by the user to achieve this, specifically something involving what "there" refers to (the object module).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I gave it another go to address your concerns. I don't know if it's good enough. Please send me something better it's not.

Copy link
Member

@CyberShadow CyberShadow Dec 9, 2018

Choose a reason for hiding this comment

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

It's better :)

mak/DOCS Outdated
$(DOCDIR)\object.html \
\
$(DOCDIR)\object__lifetime.html \
\
Copy link
Contributor

Choose a reason for hiding this comment

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

Spaces where should be tabs?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about this location, but make can be fussy about tabs vs spaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@TurkeyMan
Copy link
Contributor

Why object_/lifetime.d, and not just lifetime.d? That underscore looks pretty janky for such a fundamental package?

@JinShil
Copy link
Contributor Author

JinShil commented Dec 9, 2018

Why object_/lifetime.d, and not just lifetime.d?

There were concerns in #2222 about placing lifetime.d in the root and preventing users from being able to use lifetime.d as their own top level package. I'm actually not sure about that. @wilzbach, care to clarify?

That underscore looks pretty janky for such a fundamental package?

Actually, I just realized what @schveiguy was saying in #2222. I think I should have done core.internal.object all along. I think I'll try that. It will prevent a lot of the other changes I made as well.

@TurkeyMan
Copy link
Contributor

TurkeyMan commented Dec 9, 2018

preventing users from being able to use lifetime.d as their own top level package

So, core.lifetime? What's what I would have assumed.

@JinShil JinShil requested a review from schveiguy as a code owner December 9, 2018 08:40
@JinShil
Copy link
Contributor Author

JinShil commented Dec 9, 2018

So, core.lifetime? What's what I would have assumed.

I think we could make that work, but I'd like to keep all the publicly imported parts of object.d together as a group and segregated from the other core files. I'd be ok with it but I'm going with core.internal.object.lifetime.d until I find a reason not to.

@TurkeyMan
Copy link
Contributor

So we're gonna publicly import emplace too then? Because it's an impenetrable module name otherwise.

@JinShil
Copy link
Contributor Author

JinShil commented Dec 9, 2018

So we're gonna publicly import emplace too then?

If emplace is placed alongside destroy in lifetime.d it would be imported publicly through object.d. Noone should ever import lifetime.d directly.

@TurkeyMan
Copy link
Contributor

why does destroy need to be implicitly available? is it possible to deprecate that public import with time?

@JinShil
Copy link
Contributor Author

JinShil commented Dec 9, 2018

why does destroy need to be implicitly available?

I don't know, but now that it is, it'll take a deprecation cycle and a lot of persuasions to change.

is it possible to deprecate that public import with time?

I suppose, if you can convince the right people. There are a lot of architecture problems with druntime.

@JinShil
Copy link
Contributor Author

JinShil commented Dec 9, 2018

Damn! If you see the autotester, it's building with 2.079 which doesn't yet have the fix from https://issues.dlang.org/show_bug.cgi?id=19014. I'm sure what to do about that yet. 2.083 (the version on my local machine) also seems to still have the problem. When I build from HEAD everything works fine. @RazvanN7 @wilzbach wasn't that fix supposed to be released already?

EDIT: Looks like the fix is coming 2.084: https://dlang.org/changelog/pending.html

@adamdruppe
Copy link
Contributor

so note that none my my code are ran as part of the tests. it is just that the phobos makefile has a build rule with a similar name to my site.

@n8sh
Copy link
Member

n8sh commented Dec 9, 2018

Currently core.internal.* modules don't appear in the documentation. We could keep it that way and just add this in object.d:

version(D_Doc)
{
    /**
    Destroys the given object and optionally resets to initial state. It's used to
    _destroy an object, calling its destructor or finalizer so it no longer
    references any other objects. It does $(I not) initiate a GC cycle or free
    any GC memory.
    If `initialize` is supplied `false`, the object is considered invalid after
    destruction, and should not be referenced.
    */
    void destroy(bool initialize = true, T)(ref T obj)
    if (!is(T == class) && !is(T == interface))
    {
        import lifetime = core.internal.object.lifetime;
        lifetime.destroy!(initialize)(obj);
    }
    /// ditto
    void destroy(bool initialize = true, T)(T obj)
    if (is(T == class) || is(T == interface))
    {
        import lifetime = core.internal.object.lifetime;
        lifetime.destroy!(initialize)(obj);
    }
}
else
{
    public import core.internal.object.lifetime : destroy;
}

/**
* Contains utilities for managing lifetimes.
*
* This module is not intended to be imported or used directly. It is
Copy link
Contributor

@jacob-carlborg jacob-carlborg Dec 9, 2018

Choose a reason for hiding this comment

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

All public symbols should be package, then the user cannot use this module directly. Assuming that works since object doesn't live in a package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I make them package then they won't be visible outside of core.internal.object, right? If that's the case, then I won't be able to publicly import them into object.d.

Copy link
Contributor Author

@JinShil JinShil Dec 9, 2018

Choose a reason for hiding this comment

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

This goes along with my original idea in #2222 to put them all in the root, rename object.d to package.d and then modify the compiler to look for package.d (or the root of the runtime) instead of object.d. Then the symbols can all be made package.

There were concerns about not being able to use lifetime.d in one's own file hierarchy. But, honestly, I don't understand that, because they would be under a different folder and users should never import the runtime's lifetime.d anyway.

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 possible to specify a symbol along with package, i.e. package(core) which would make it accessible to the whole core package and all its sub packages. But since object lives outside any package, that might not work anyway.

@JinShil
Copy link
Contributor Author

JinShil commented Dec 9, 2018

Currently core.internal.* modules don't appear in the documentation.

Yes, I'm aware and working on that. My current workaround is https://github.com/dlang/druntime/pull/2399/files#diff-a68e58fcf0de5aa198fcaceafe4e8cf9R6 That's a statement in object.d's documentation comment that reads...

* This module publicly imports symbols from $(REF ,core,internal,object,lifetime).

... if I can only get the link to work right (If you know the correct DDoc syntax for the link, please do tell). You can see it rendered here.

I don't really want to do your version(D_Doc) workaround because the documentation should accompany the implementation in lifetime.d and we'd have to duplicated in both places, thus trading one maintenance headache for another.

I also tried mixin(import("core.internal.object.lifetime.d")), but the compiler didn't generate the docs then either.

There's actually an issue report already documenting that this isn't working right: https://issues.dlang.org/show_bug.cgi?id=10665 I'm going to try to fix that tonight. If I'm successful, the problem will just go away and we'll all have one less annoyance to deal with in our own code.

@JinShil
Copy link
Contributor Author

JinShil commented Dec 16, 2018

Due to Issue 19014 This needs the autotester upgraded to 2.084 before it can move forward. Closing until that becomes reality.

@JinShil JinShil closed this Dec 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants