shared - i need it to be useful

12345swordy alexanderheistermann at gmail.com
Tue Oct 23 01:24:58 UTC 2018


On Tuesday, 23 October 2018 at 01:21:32 UTC, Neia Neutuladh wrote:
> On Tue, 23 Oct 2018 00:08:04 +0000, 12345swordy wrote:
>> Quick question, if a class import a module in its scope, does 
>> it carry its own copy when creating multiple objects with it?
>
> Importing a module doesn't make a copy of any code. Each module 
> contains only its own code. Importing modules makes it so you 
> can access their code, nothing more.
>
> Instances of a class don't contain private copies of their own 
> code. There's only one copy per executable. So even if 
> importing a module made a copy of the code, you'd still only 
> have one copy per type, not per object.

Huh, that what I figured. Though it not easy to test it as you 
literally have to create two files for this.


More information about the Digitalmars-d mailing list