-
-
Notifications
You must be signed in to change notification settings - Fork 668
Fix Issue 18505 - delete deprecation message is misleading #7947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Shouldn't we direct people to |
|
I was under the impression that We need to revisit the motivation and rationale for deprecating |
Well, in general yes, but https://dlang.org/changelog/2.079.0.html#core-memory-__delete As mentioned, I don't think recommending calling
You were the one who pushed the deprecation through its final stage, but AFAICT the motivation is simple:
As mentioned, When https://dlang.org/deprecate.html#delete was written, Anyhow I didn't want to start a major discussion, I was just saying that we should either mention |
|
I'm fine with using If anything, the pitfalls of I'd really like a function that I can call (if |
From what I can tell |
|
@JinShil I think the issue is this: https://run.dlang.io/is/yS5hHE In other words, It works on static arrays and stack-based structs, because those are value types. But you wouldn't be using |
|
@schveiguy Ok. I understand what you mean. But it does work for heap allocated structs if you use About heap allocated arrays. Should
I fully understand that, but it was my understanding that we didn't want people to be using the delete idiom any more, and users were to be encouraged to refactor their code to make it support the |
Right, but is that what people will use? It's a pitfall that I feel is completely non-obvious. They will call We don't have the same problems with classes, though admittedly they are a different animal.
I'm unsure. I don't think it should follow pointers from inside the array elements. But I would expect
Note that there are legitimate reasons to eagerly deallocate memory. The conservative GC can cause problems in some cases when you leave behind a giant block of data. So there still is a need to free data. This was the major reason why
IMO, the struct case as you say is trivial to overcome (just use *s), we should make sure it's clearly documented. It's the array case that's troublesome to me. If we could solve that, then I think the need for |
I need to think this through more, I welcome suggestions. |
See dlang/druntime#2104 for context
cc @schveiguy, @dkgroot, @wilzbach