On 02/08/12 00:32, Sean Kelly wrote:
> [...] the transitivity of shared can still make for some weirdness at the 
> implementation level.  For example, if I have:
> 
> class Thread {
>     pthread_t p;
>     shared void detach() {
>         pthread_detach(p);
>     }
> }
> 
> Building this yields:
> 
> Error: function core.sys.posix.pthread.pthread_detach (_opaque_pthread_t*) is 
> not callable using argument types (shared(_opaque_pthread_t*))
> Error: cannot implicitly convert expression (this.p) of type 
> shared(_opaque_pthread_t*) to _opaque_pthread_t*
> 
> So I either need to speculatively update a bunch of system API calls to add a 
> 'shared' qualifier to everything I think will always be used in a shared 
> context, or explicitly cast away shared when actually passing these variables 
> to their associated API routines.  Neither option is appealing, so again I 
> haven't done anything regarding shared.

An overload would work, right?

class Thread {
    pthread_t p;
    shared void detach() {
        pthread_detach(p);
    }
    void detach() {
        pthread_detach(p);
    }
}

And, yes, without a class similar to inout, this is not really a solution.

artur

Reply via email to