www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - delete & its deprecation

reply bauss <jj_1337 live.dk> writes:
Are there any plans to completely remove the delete keyword so 
members of ex. a class can be called delete? Or is there still 
code within DMD or Phobos that uses it?
Oct 27 2017
parent reply Jonathan M Davis <newsgroup.d jmdavisprog.com> writes:
On Friday, October 27, 2017 12:30:58 bauss via Digitalmars-d wrote:
 Are there any plans to completely remove the delete keyword so
 members of ex. a class can be called delete? Or is there still
 code within DMD or Phobos that uses it?
It's been the plan for ages that delete was to be deprecated, but no one has ever bothered to do it. Part of the problem has been that while it was possible to construct a class into memory allocated with something other than new and than destroy it later, it was actually pretty difficult to get right. If it weren't for that, I probably would have pushed for its removal ages ago. However, now that we have std.experimental.allocator, things have changed a bit, and it should be far more reasonable to get rid of delete. But still, someone has to actually go and deprecate it, and I think that it's more or less been forgotten. Nothing in Phobos uses delete, and it looks like the only place that uses delete in druntime is some unit tests. I doubt that any of the core D developers have done anything with delete in years, which would be part of why it's easily forgotten. I know that I tend to forget that it's even part of the language. - Jonathan M Davis
Oct 27 2017
parent 12345swordy <alexanderheistermann gmail.com> writes:
On Friday, 27 October 2017 at 19:03:01 UTC, Jonathan M Davis 
wrote:
 On Friday, October 27, 2017 12:30:58 bauss via Digitalmars-d 
 wrote:
 Are there any plans to completely remove the delete keyword so 
 members of ex. a class can be called delete? Or is there still 
 code within DMD or Phobos that uses it?
It's been the plan for ages that delete was to be deprecated, but no one has ever bothered to do it. Part of the problem has been that while it was possible to construct a class into memory allocated with something other than new and than destroy it later, it was actually pretty difficult to get right. If it weren't for that, I probably would have pushed for its removal ages ago. However, now that we have std.experimental.allocator, things have changed a bit, and it should be far more reasonable to get rid of delete. But still, someone has to actually go and deprecate it, and I think that it's more or less been forgotten. Nothing in Phobos uses delete, and it looks like the only place that uses delete in druntime is some unit tests. I doubt that any of the core D developers have done anything with delete in years, which would be part of why it's easily forgotten. I know that I tend to forget that it's even part of the language. - Jonathan M Davis
It certainly doesn't help when there are bugs regarding destroy function. -Alexander Heistermann
Oct 28 2017