Conversation
|
Awesome. |
|
Github doesn't have messaging, so I'll just post this here: @WalterBright @yebblies @9rnsr @donc @braddr @MartinNowak @andralex @ibuclaw @rainers @klickverbot: |
|
I think there's a problem with nothrow here. What if we duplicate |
|
@AndrejMitrovic is there a relationship between the DMD Source Guide and this pull request? |
No, Github foolishly got rid of messaging so this is left as one of the workaround ways of notifying people. |
|
Hmm, I didn't consider postblit. Will fix. |
|
Wasn't there a PR that moved |
Was: dlang/druntime#298 |
|
Let's fix this now and move it to druntime later. |
|
This means |
Obviously, the argument also holds against unconditionally marking it as |
True that, so does it even make sense to implement this in the compiler when a simple runtime template would do attribute inference? T[] dup(T)(T[] arr)
{
auto res = new T[](arr.length);
res[] = arr[];
return res;
} |
|
@MartinNowak the code is less efficient than it should be because the new call initializes the memory. Anyhow the point is well taken: if we can move dup from the compiler to |
|
Looking at the amount of code dedicated to this, my conviction is even stronger. Let's move dup into the library!!! |
To obtain GC.memory with standard appendable chunk and non-initialization, one can simply use druntime's reserve, followed by assumeSafeAppend (or From there, The problem here is that while all this is doable in druntime, we'd still just be at square 1, where we wouldn't actually have the correct inference :/ on all of that. |
|
@monarchdodra what would be the attribute inference there? |
That's my point: Implementing dup as a high efficiency druntime function lacks a "direct postblit call" that would trigger inference. |
|
I still don't understand but no matter. Bottom line is less compiler magic and more D stuff that actually looks and feels like legit D code == good. |
|
new plan: dlang/druntime#758 |
This adds attributes pure, nothrow, and @trusted to the .dup internal function.
It also allows for better unique detection on the arguments to adDup(). For example,
adDup(null)should be implicitly convertible.