Sharing in D

Steven Schveighoffer schveiguy at yahoo.com
Fri Aug 1 07:35:06 PDT 2008


"JAnderson" wrote
> Steven Schveighoffer wrote:
> <Snip>
> >
> > dmd mycode.d
> > Error: when calling foo(shared int *), cannot pass int *
> >
> > edit mycode.d, cast to shared int *
> >
> > OK, now it works :)   Probably without any problems, because the
> compiler has no idea whether I'm going to change it in another thread. 
> Hell, I might not even HAVE more than one thread!
> >
> > But the result is, we're back to the same model as before.  And now I
> have to cast everything.   Annoying.
> <Snip>
>
> The idea behind compile-time checking like this is that you can quickly 
> identify errors.  If someone writes something in a lib you use that is not 
> share safe, you'll know right of the bat.

I believe the direction that this is heading is promising, but my concern is 
that it actually won't be helpful as currently described.  Because I don't 
think you can implicitly cast shared to unshared and vice versa, you will 
need to populate your code with casts wherever you cross the boundaries.  If 
this is a lot, then you will end up creating too much noise to be able to 
find the problems.

This model seems equivalent to having mutable and invariant, but not const 
(the link between).

-Steve 





More information about the Digitalmars-d mailing list