Skip to content

Conversation

@JinShil
Copy link
Contributor

@JinShil JinShil commented Mar 16, 2018

delete was deprecated in 2.079. Before the delete keyword can be removed it will be necessary to also deprecate and remove class allocators and deallocators. They have been planned for deprecation for years; this PR finally puts the deprecation process in motion.

See https://dlang.org/deprecate.html#Class%20allocators%20and%20deallocators

DMD PR: dlang/dmd#8042

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @JinShil!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

@adamdruppe
Copy link
Contributor

So we recently found @disable new is actually kinda cool....

@JinShil
Copy link
Contributor Author

JinShil commented Mar 16, 2018

So we recently found @disable new is actually kinda cool....

Please elaborate.

@adamdruppe
Copy link
Contributor

struct S
{
  @disable new (size_t s) { return null; }
}

void main()
{
	S* s = new S; //  Error: allocator `e.S.new` is not callable because it is annotated with @disable
}

@adamdruppe
Copy link
Contributor

So the application there is you can force users to go through your custom factory functions, or in the case of structs, put them on the stack (or bypass with memcpy lol).

@JackStouffer
Copy link
Contributor

See dlang/phobos#6003 for an example.

@JinShil
Copy link
Contributor Author

JinShil commented Mar 16, 2018

I've added support for the syntax @disable new(); to the DMD PR. You won't even need to add the useless size_t argument. That should prevent any breaking changes.

@adamdruppe
Copy link
Contributor

That sounds good to me!

@JinShil
Copy link
Contributor Author

JinShil commented Mar 17, 2018

That sounds good to me!

Great! If you don't mind, and truly approve of this PR, please take the explicit step of marking it "Approved".

@adamdruppe
Copy link
Contributor

oh lol i keep forgetting i actually have some power in this repo. I don't have such power over on the dmd side though.

@JinShil
Copy link
Contributor Author

JinShil commented Mar 17, 2018

I don't have such power over on the dmd side though.

I still think it's helpful to mark PRs "approved" even in repos where you may not have merge rights. It helps to know that it was reviewed and scrutinized by anyone with D language skills, especially a veteran like yourself.

@wilzbach
Copy link
Contributor

Shouldn't this PR remove or mark as deprecated the respective sections in the spec too?
e.g.
https://dlang.org/spec/class.html#allocators

@JinShil
Copy link
Contributor Author

JinShil commented Mar 18, 2018

Shouldn't this PR remove or mark as deprecated the respective sections in the spec too?

The spec already states the following for allocators:

Note: Class allocators are deprecated in D2.

... and the following for class deallocators

Note: Class deallocators and the delete operator are deprecated in D2

I remember a brief discussion we had with one of the other deprecations in 2.079 to leave the spec in tact until removal (See #1941 (comment)) so users could still refer to it when updating their code. Therefore, since the spec has already marked allocators and deallocators as deprecated, I think the spec should be left as is until removal.

@JinShil JinShil added the Vision https://wiki.dlang.org/Vision/2018H1 label Mar 23, 2018
@JinShil
Copy link
Contributor Author

JinShil commented Apr 1, 2018

Ping! DMD PR was merged.

@adamdruppe adamdruppe merged commit 8fc54e0 into dlang:master Apr 1, 2018
@JinShil JinShil deleted the deprecate_class_allocators branch April 24, 2018 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Vision https://wiki.dlang.org/Vision/2018H1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants