An Issue I Wish To Raise Awareness On

Jack Stouffer via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 19 08:38:08 PDT 2017


On Wednesday, 19 July 2017 at 14:56:58 UTC, Dukc wrote:
> Shouldn't it be :
> struct A
> {
>     ~this() shared {}
> }
>
> void main()
> {
>     auto a = A();
>     shared b = A();
> }
> ?
>
> Because handling theard-local data as shared is safe as far as 
> I remember, but not the other way round.

Non-shared structs/classes can't call shared methods.

Unless you're saying that the above should work even though it 
currently doesn't. Even then, I don't know about that. If your 
type is complex enough to need a shared dtor then the dtor 
probably needs to do some locking or extra checks. You don't want 
to impose that cost on a struct instance which isn't shared.



More information about the Digitalmars-d mailing list