-
-
Notifications
You must be signed in to change notification settings - Fork 411
Partially revert some changes to object.d: destroy and array capacity functions #2784
Conversation
|
It might be easiest to review each commit separately. |
|
|
|
@ZombineDev I thought about that, but these are language-defined symbols not library-defined symbols. Right or wrong, they're available to all programs without having to import anything. I worry that by placing them in a public module like I think if we want to go further than what I've already done we should split |
|
That being said, I'd be ok with moving things to |
I don't want to get into nitpicking, but IMO language-implementation symbols are all those On the other hand I thought about turning |
Let's wait for other reviewers to chime in. |
|
I want to leave reviewers with something to consider: If, for example, static import core.array: length;
writeln(core.array.length(myArray));That isn't idiomatic D, but by moving the symbols to If you'd like me to continue cleaning up If you'd like me to put an end to the refactoring (at least for now), I recommend pulling this PR. But, again, I'll do whatever the community decides. |
That seems fine to me. |
You could declare |
That won't work well due to documentation. When publicly imported the import declaration will contain a link to the Example: /// See $(REF __length, core,array) --> redirects user to `core.array.__length` documentation
public import core.array : length = __length; |
|
Well, if |
|
Right. so then I don't see moving it to |
|
Can we please stop with all these endless code reshufflings? I don't think they matter at all, for the simple reason that I can never predict where any function is. I use
|
|
Ping. Please understand why these refactorings were done. We have an ongoing effort to convert some runtime hooks to templates to avoid dependency on runtime type information and to make D a more pay-as-you-go language. If we keep moving said converted templates to object.d, we'll eventually have the entire runtime in object.d. Furthermore, object.d is currently unwieldy causing merge conflicts and horrendous diffs for simple changes. This PR is the last of the refactorings bringing that effort to a close. More could be done, but the tolerance for these refactorings has faded, and with the refactorings done recently, moving templated runtime hooks to object.d is no longer an escalating problem. Please merge this PR so we can bring this refactoring effort to a close. It's the last one for this stage of work. Thank you. |
|
So what about the forwarding function idea? Also, if you put the import inside the function, it will speed up compiling programs that never call these functions. |
By "forwarding function idea", I think you're referring to this... size_t hashOf(T)(auto ref T arg)
{
static import core.internal.hash;
return core.internal.hash.hashOf(arg);
}... instead of... public import core.internal.hash : hashOf;Yes, that would be nice to avoid the import until the template is instantiated. However, there are a couple of issues with it.
|
But it does scale with the number of imports avoided! If one repeats an "it's just one millisecond" argument a thousand times, it's no longer just one millisecond. I agree with everything else, thanks. |
After the fix in dlang/dmd#10365 and accompanying druntime PRs #2772 and #2783, most of the
core.internalAPI is undocumented (as it should be). Because thecore.internalmodules do not appear in the documentation, they are no longer a good place to put thedestroyand array capacity functions because they are intended to be used by the user. This PR partially reverts #2772 and #2647 so function intended for the user are all in object.d and functions that are intended to be used only by the compiler remain incore.internal.This is the last PR I intend to submit to clean up object.d. I'm fairly happy with the result. More could be done, such as making
objecta package instead of a file, but I think I've done enough for now and set a good precedent distinguishing functions intended for the user and functions intended only for the compiler.