Jason House Wrote:

> I'm glad to see I'm not the only one trying to use shared. I tried to use it 
> with 2.031 and rapidly hit bug after bug... I submitted several bug reports 
> for basic functionality, and none of it appeared in the changelog.
> 
> http://d.puremagic.com/issues/show_bug.cgi?id=3089

shared methods no longer trigger errors in 2.032, this issue should be marked 
as fixed, it must be a side effect from fixing another issue.

> http://d.puremagic.com/issues/show_bug.cgi?id=3090

I just made a quick template this seems to work in 2.032:

immutable template isShared(T) {
        static if(is(T U : shared U))
                bool isShared = true;
        else
                bool isShared = false;
}

> http://d.puremagic.com/issues/show_bug.cgi?id=3091

This one still isn't solved, I too found it annoying that you cant use 'new 
shared Foo()'. You can however declare Foo as 'shared class Foo', this works 
just like 'immutable class' or 'const class' by marking all properties and 
members with the qualifier. As a side note, I would like the same behavior for 
'static class'.

However using 'shared class' is not always the wanted behavior, you may only 
want a subset of the members and properties to be shared.

We also miss a unique qualifier to allow unshared objects to be used in shared 
contexts without the need for shared methods.

It's also awkward to use, const members may be called from either const or 
mutable objects. Shared members must be called from shared objects, so why 
allow a class to have shared and unshared members, if all instances are going 
to be shared anyways? It makes it much harder to draw the line between shared 
and unshared; you may have only a few objects actually shared, but you are 
required to make all the other objects they may use shared, even if they are 
synchronized or unique. This makes all the other contexts these objects are 
used in as shared, and soon your entire program is shared.

Reply via email to