Sharing in D
Sean Kelly
sean at invisibleduck.org
Fri Aug 1 09:52:14 PDT 2008
== Quote from Sean Kelly (sean at invisibleduck.org)'s article
> == Quote from superdan (super at dan.org)'s article
> > Steven Schveighoffer Wrote:
> > > "Walter Bright" wrote
> > > >
> > > > Non-shared can be implicitly cast to shared, as that is always safe. Just
> > > > not the other way.
> > >
> > > How is that possible?
> > >
> > > shared int *x;
> > >
> > > void foo(shared int *y)
> > > {
> > > x = y;
> > > }
> > >
> > > int *x2;
> > >
> > > void bar()
> > > {
> > > foo(x2);
> > > }
> > >
> > > After calling bar, isn't x2 now both shared (as x) and unshared at the same
> > > time? I think you need casts for both ways.
> > looks like walt has a problem in his hands :))
> That, or 'shared' applies only to the pointer, not to the value being pointed to.
> However, given the const system I'd be inclined to think that 'shared' may be
> transitive, in which case yeah, you've got a problem :-)
Err... I spoke too soon. Not a problem because then the
value would have to be shared as well. I'd guess this is
how it will work. Viral, just like const.
Sean
More information about the Digitalmars-d
mailing list