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
Fix Issue 9433 - Deprecate delete #7342
Conversation
delete is still required for cases like https://issues.dlang.org/show_bug.cgi?id=17230 |
That is due to a separate bug: https://issues.dlang.org/show_bug.cgi?id=17267. Once that bug is fixed, you should be able to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it was planned for 2.072, there's a real chance we might see this deprecation for 2.078 🎉
src/ddmd/parse.d
Outdated
@@ -7770,6 +7770,10 @@ final class Parser(AST) : Lexer | |||
case TOKdelete: | |||
nextToken(); | |||
e = parseUnaryExp(); | |||
// 1. Deprecation for 1 year | |||
// 2. Error for 1 year | |||
// 3. Removal, "delete" can be used for other identities |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using a similar deprecated pattern as in Phobos?
// @@@DEPRECATED_2017-12@@@
In any case, it would be good to start using easily greppable years into the source code, s.t. these deprecations don't get forgotten.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// @@@DEPRECATED_2017-12@@@
How can I be sure that this will be merged this month? Maybe just add @@@DEPRECATED@@@
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The trick is to annoy @andralex and @WalterBright daily ;-)
Okay all jokes aside, at Phobos these deprecation strings are put in a PR and this has never been a huge problem as at least for Phobos deprecation PRs are merged rather quickly. Yep, there have been cases in which a PR has been merged later, but it hasn't been a big deal whether a deprecation lasted for 23 or 24 months. On the contrary (1) with Martin's polished release two months release cycle, it's still 9 or 10 releases (compared to 3-4 releases two or three years ago) and people are now complaining that the deprecation periods are too long. And secondly (2) the obvious advantage is that someone will actually switch the deprecation to an error.
Anyhow, the deprecation cycle is rather ill-defined as of now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I added @@@DEPRECATED_2017-12@@@
.
Btw could you also send a respective PR to dlang.org, s.t. the update of the deprecation page doesn't get lost? (Unfortunately this tends to happen too often). |
|
@WalterBright and @andralex Can I please get a ruling on this? I think time is running out for the 2.078.0 release. |
I had a short chat with @andralex about this last week and the only thing he was worried about was that no drop-in replacement for However, after looking at it for a bit, I don't see any reason why people if
|
Why does a drop-in replacement need to exist if it's deprecated?
Clever! 👍 |
The idea here is purely operational - someone who has a codebase using |
src/ddmd/parse.d
Outdated
// 1. Deprecation for 1 year | ||
// 2. Error for 1 year | ||
// 3. Removal, "delete" can be used for other identities | ||
deprecation("The `delete` keyword has been deprecated. Use `object.destroy()` instead."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
destroy
is not a pound-for-pound replacement for delete
.
changelog/deprecate_delete.dd
Outdated
|
||
See the $(LINK2 $(ROOT_DIR)deprecate.html#delete, Deprecated Features) for more information. | ||
|
||
Starting with this release, using the `delete` keyword will result in a deprecation warning. The warning is scheduled to remain for 1 year, after which it will be changed to an error. The error is then to remain for 1 year, after which `delete` will be removed as a keyword. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changelog should specify the replacement function.
@wilzbach _d_delclass would be suitable. It's not an easy replacement, but probably we don't want to make it too easy. |
How long would such a recipe need to be maintained? I understand the value of having such a recipe to make for smoother transition, but don't we eventually want to usher users away from such things and encourage them to refactor their code so they can make use of I'll do the legwork, but I need to a more concrete roadmap. |
There's no significant burden to having a function in the standard library that does what |
Ok. Thanks. What's our recommendation to users, then? "Prefer |
@JinShil yes, something along these lines. |
@wilzbach I'll make changes as soon as I know what function to direct users to. |
Yes. I'm sorry that you missed 2.078 :/ |
Finally managed to get to it: Sorry for the long delay |
This is ready for additional scrutiny and potential merge, now that dlang/druntime#2037 is in. |
changelog/deprecate_delete.dd
Outdated
warning is scheduled to remain for 1 year, after which it will be changed to an error. The | ||
error is then to remain for 1 year, after which `delete` will be removed as a keyword. | ||
|
||
As a replacement, users are encouraged to use $(LINK2 $(ROOT_DIR)phobos/object.html#.destroy), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be phobos
in the link?
The links to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: there are plans to use scheduled versions instead of scheduled date. The upcoming DIP also mentions a few other things - I am not saying that you need to apply them hear, but I think it doesn't hurt to have a look at what could be the mandatory soon.
changelog/deprecate_delete.dd
Outdated
|
||
Starting with this release, using the `delete` keyword will result in a deprecation warning. The | ||
warning is scheduled to remain for 1 year, after which it will be changed to an error. The | ||
error is then to remain for 1 year, after which `delete` will be removed as a keyword. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you aware of Jack's new deprecation DIP?
dlang/DIPs#108
One of the things that are on the list is instead of having a fixed date, a fixed version is better for users because it's important which version will stop supporting it (there might be a few delay of publishing a version, e.g. LDC or distros in general)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I've seen the DIP, but it needs to go through a review and approval process which I think will take time. Given the the fact that we don't have a well-defined deprecation process, I made something up, and that's what you see here. Feel free to suggest an alternative wording, or maybe I should just omit the schedule altogether so we don't have to commit to anything. I don't have an opinion either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please omit the schedule from the changelog.
In my experience, we most likely won't stick to it anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Nothing to worry about - __delete hasn't been released yet and is only visible on the preview pages: http://dtest.dlang.io/artifact/website-f9fb5f80bc0b4127acd5d08058b245ed9a9cabb3-677d592a5d032c630664b91a89c8a0af/web/phobos-prerelease/core_memory.html#.__delete |
What about |
From https://github.com/dlang/dlang.org/blob/master/dlang.org.ddoc#L353
Argh... -> |
REF1 is currently only used once in entire DRuntime and Phobos, so maybe a special OBJECTREF macro would have been better? Anyhow, have a look at the only use of `REF1` to understand the motivation for this PR: https://dlang.org/phobos/std_file.html#.thisExePath Also there are three other PRs being blocked on this: - dlang/dmd#7342 - dlang/druntime#2082 - dlang/phobos#6140
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks all good to me. Thanks for pushing this!
See:
https://dlang.org/deprecate.html
https://dlang.org/deprecate.html#delete
http://forum.dlang.org/post/jzldqlkxgewtxjyffekb@forum.dlang.org
http://forum.dlang.org/post/gqgnquwhmykvpafwpemr@forum.dlang.org
Spec and Documentation Update: dlang/dlang.org#1941.
There are only 5 lines of code change in this PR, and 4 of them are comments. The rest are mostly line number changes for the test suite, as many of the tests now emit a deprecation warning in addition to their other output.