On Thursday, 20 July 2017 at 21:20:46 UTC, Jonathan M Davis wrote:
On Thursday, July 20, 2017 07:40:35 Dominikus Dittes Scherkl
via Digitalmars-d wrote:
On Wednesday, 19 July 2017 at 22:35:43 UTC, Jonathan M Davis
wrote:
> The issue isn't the object being destroyed. It's what it
> refers to via its member variables. For instance, what if an
> object were to remove itself from a shared list when it's
> destroyed (e.g. because it's an observer in the observer
> pattern). The object has a reference to the list, but it
> doesn't own it.
So, even a thread-local object that has references to a shared
list
has to handle those as shared, even in its non-shared
destructor.
I can't follow your argument.
You can't just strip off shared. To do so defeats the purpose
of shared. If you have something like
struct S
{
shared List<Foo> _list;
~this()
{
...
}
}
This is fine. What dmd does now is strip shared off of the `this`
pointer, not the member variables. There's only a problem if the
sharedness of the member variable(s) depends on sharedness of the
enclosing object.
then inside of the destructor, _list is not treated as shared,
It is.
Atila