'with' bug?

Faux Amis faux at amis.com
Sun Nov 4 16:08:41 PST 2012


On 05/11/2012 00:58, bearophile wrote:
> Faux Amis:
>
>> I think there is nothing wrong with a module scope private var as in D
>> a module is the first encapsulation and adding a wrapper only adds noise.
>
> Generally it's better to minimize the scope of variables. So if you wrap
> a variable inside a struct you have often reduced its scope, unless the
> module contains only one variable and only one struct :-)
>
> Often it's better to pass variables as arguments.
>
> Again, in D "pure" is your good friend.
>
> Bye,
> bearophile

Is there any reason to encapsulate this kind of code in a struct?
---
module a;

private int _a;

int a(){
   return _a;
}

void a(int aIn){
   _a = aIn;
}

void useA(){
}
---
module main;

static import a;

void main(){
   a.useA();
}
---


More information about the Digitalmars-d mailing list