Unintuitive behavior with shared classes & template member functions; is this intended?

Jaime benjamin.i.mccann at gmail.com
Sun Jan 16 20:12:49 UTC 2022


On Saturday, 15 January 2022 at 02:52:20 UTC, Steven 
Schveighoffer wrote:
> you probably can fix the issue via:
>
> ```d
> class C
> {
> shared:
>    ... // everything
> }
> ```

This seems like a good solution. To achieve implicit sharing on 
the aggregate itself, I can use this approach to define a 
[Voldemort type](https://wiki.dlang.org/Voldemort_types), and 
declare the intended name as an externally visible alias to that 
type.

Something like this (untested):

```d
alias MyClass = shared(typeof(({
     class MyInvisibleClass {shared {
         // things
     }}
     return cast(MyInvisibleClass)(null);
})()));
```

Whether this is a good thing to do, of course, is debatable.

> Please file:  https://issues.dlang.org
>
> -Steve

Unfortunately I cannot; despite my repeated attempts, the 
Bugzilla instance is not sending me a confirmation email to 
register an account. This problem has persisted for a day or so, 
so I doubt the emails will eventually come through.

I apologize. If anyone reading would care to file this issue on 
my behalf, I would be much obliged.


More information about the Digitalmars-d-learn mailing list