An Issue I Wish To Raise Awareness On

Marco Leise via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 19 05:56:38 PDT 2017


Am Wed, 19 Jul 2017 08:50:11 +0000
schrieb Kagamin <spam at here.lot>:

> On Tuesday, 18 July 2017 at 19:24:18 UTC, Jonathan M Davis wrote:
> > For full-on value types, it should be a non-issue though.  
> 
> Not quite. Value types include resource identifiers, which may 
> have threading requirements, e.g. GUI widget handles and OpenGL 
> handles, assuming they are thread-safe and making them implicitly 
> shared would be incorrect.

That's exactly what I was opposing in the other post. These
handles are opaque and never change their value. Within the
Dlang language barrier they can be immutable and as such,
implicitly shared.
Your thinking is less technical, trying to find a best fit
between type system and foreign API, so that only handles with
a thread-safe API may become `shared`. I like the idea, but it
is impractical. It sometimes depends on whether a library was
compiled with multi-threading support or not and a value type
can be copied from and to shared anyways, rendering the safety
argument void:

	int x;
	shared int y = x;
	int z = y;

-- 
Marco



More information about the Digitalmars-d mailing list