-
-
Notifications
You must be signed in to change notification settings - Fork 694
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 15829 - hasElaborateDestructor doesn't work for classes #4119
Conversation
|
I'm not sure if I should add support for interfaces. |
@andralex It seems you're the original writer of this, so was there any specific reason this was limited to structs? |
@ZombineDev, about interfaces. No need to support them: interfaces can't have a |
@bbasile that's also what I thought, but I didn't have time to investigate last night, so I decided to ask. BTW, in .NET there is a special interface called IDisposable that is recognized by the compiler / GC. It has a
When you schedule a task(function) for async execution, the I'm wondering if it is a good idea to allow interfaces that define |
It seems that this would be a breaking change if it's accepted. I'll investigate if there is much work needed to make the whole Phobos test suite pass. |
I'd argue that classes don't have a destruct but rsther finalizer. As such finalizer is not called on copy( reference type) unlike struct dtor which is what is checked by this trait everywhere. |
@DmitryOlshansky the problem is that existing code already relies on |
We can either fix all code in existance that incorrectly uses it and put a warning in the documentation of |
There pretty much is already:
|
So we need to add a new function |
I can see how the current trait is useful deliberately by not supporting class references. If we need a trait that supports them too, it probably shouldn't use the word elaborate - I think that word is how the existing design differentiates its destructor terminology from class destructors. I accept elaborate isn't the clearest word though. |
Ping as a rebase is needed. How about we deprecate hasElaborateDestructor and replace it with the fixed version? |
The thing is - elaborate destructor is specifically about struct-style destructor that is called on out of scope. So adding a hasElaborateFinalizer might be better.... |
Then fix the name of elaborateDestructor (seems to be a unique D creation) ;-)
+1
|
I would like to get @andralex's opinion on this issue. I really don't see why anyone would want a trait that works only with structs, especially when if you needed that you could do @DmitryOlshansky dtors have nothing to do with value vs. ref semantics ( |
To hell with nogc, the whole point is determinism. Take a look at std.algo.move - when moving things around manually one has to know if there is struct destruct not class (class is safe to bit-blit, it's a pointer) |
|
As I said earlier, the dtor matters only when the object is destroyed. (If you are wondering why would you need a container of possibly polymorphic types to store it's elements inplace - it's a common perf optimization - see http://bannalia.blogspot.bg/2014/05/fast-polymorphic-collections.html?m=1 ) |
@ZombineDev makes sense, I think I'm convinced |
So to truly replace |
@ZombineDev If you're waiting on @andralex's opinion, then you should email him |
The intent of |
@andralex but what should we do about code like in |
I agree completely with @ZombineDev in this regard! I'm also missing And if |
No description provided.