What is shared functions?

mta`chrono chrono at mta-international.net
Wed Oct 26 00:14:56 PDT 2011


> void main() {
>     shared s1 = cast(shared)new S();
>     s1.onlyShared(); // ok
>     //s1.notShared(); // error: not callable using argument types () shared
>     auto s2 = new S();
>     //s2.onlyShared(); // error: not callable using argument types ()
>     s2.notShared(); // ok
> }

I would rather prefer "auto s1 = new shared(S);" because "shared s1 =
new S();" seems to allocate a TLS variable which is then casted to
shared which is actually non-TLS.


More information about the Digitalmars-d-learn mailing list