shared - i need it to be useful

Manu turkeyman at gmail.com
Mon Oct 15 21:08:38 UTC 2018


On Mon, Oct 15, 2018 at 2:05 PM Nicholas Wilson via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> On Monday, 15 October 2018 at 20:54:12 UTC, jmh530 wrote:
> > On Monday, 15 October 2018 at 20:44:35 UTC, Manu wrote:
> >> snip
> >>
> >> Are you saying `is(immutable(int) == shared) == true)` ??
> >
> > From the spec:
> > "Applying any qualifier to immutable T results in immutable T.
> > This makes immutable a fixed point of qualifier combinations
> > and makes types such as const(immutable(shared T)) impossible
> > to create."
> >
> > Example:
> >
> > import std.stdio : writeln;
> >
> > void main()
> > {
> >     writeln(is(immutable(int) == shared immutable(int)) ==
> > true); //prints true
> > }
>
> The philosophy of this is that: the value never changes,
> therefore only one copy of the variable needs to exist (i.e.
> immutable variables declared at module scope are _not_ thread
> local) and can be shared between threads with no race conditions.
>
> I'm saying that while what you propose sounds very reasonable, we
> should make sure that reading immutable variables is still good ;)

I don't think what I describe affects immutable in any way;
`is(immutable(int) == shared) == false`, as it should be. Immutable
wouldn't have its rules affected by any change to shared.


More information about the Digitalmars-d mailing list