Is it possible to elegantly craft a class that can be used as shared and as normal?

Tolga Cakiroglu tcak at pcak.com
Sun Mar 2 12:23:25 PST 2014


On Sunday, 2 March 2014 at 20:16:42 UTC, Gary Willoughby wrote:
> On Sunday, 2 March 2014 at 18:04:06 UTC, Dicebot wrote:
>> shared and non-shared entities have different implementation. 
>> You unlikely want to have one for both.
>
> It's part of my unit-testing toolkit that handles mocking of 
> objects. I want to use the same code to handle shared and 
> non-shared entities.

I didn't like this feature as well, though after a while, you 
start getting used to it. Anyway, defining all methods as shared, 
using `cast()` when you don't want to use it as non-shared can be 
the best option for you I think. I discovered that `cast()` 
recently, and was writing whole class name all times.


More information about the Digitalmars-d-learn mailing list