Non-ugly ways to implement a 'static' class or namespace?

Ali Çehreli acehreli at yahoo.com
Fri Feb 10 00:18:59 UTC 2023


On 2/9/23 15:58, thebluepandabear wrote:
 >> In contrast, I use D every day and love its relaxed attitude towards
 >> private.
 >
 > the fact that private stuff is accessible from other classes in the same
 > module is really really bad, and it's pretty detrimental to the language.

Not everybody shares that view. So, there must be something deeper here: 
maybe some people are blind (including me), or others have expectations 
that they carry from other languages, or something else... But look at 
the contrast: Some people see the same thing as great and some people 
see it as really really bad.

One thing is clear: We can't agree on this topic at least at this time.

 > let's actually think about what `private` means.

It gives implementation freedom: I can change my implementation at will.

The same exact goal can be achieved by convention as well: I can name my 
members with e.g. an underscore and everybody understands that they are 
private. Nobody touches it and they are protected from future 
implementation changes.

If they do, they do it with full understanding that their code may break 
in the future.

 > when you come back from work, arrive home, and you close the curtains
 > and want some alone, you want to be private to everyone.

I don't agree with that example: Yes, it's the same word but different 
meanings in code.

 > you wouldn't want your neighbours (the module) to peek at what you're
 > doing.

Yes but I would have no problem other code looking at or using parts of 
my code if they wanted to.

 > your neighbours aren't your friends in real life,

There is some friendship with my neighbors! :)

 > and they (the module)
 > aren't your friends in code

Some of them are and some aren't.

 > -- just because they are in your vicinity
 > doesn't mean they have a right to violate your privacy.

Right to violate doesn't mean anything will be broken. It means, there 
will be no hurdle if access is needed. Nobody will or does violate 
anything. I haven't seen a single time when D's approach to privacy 
caused harm.

 > tbh this whole private behaviour should be changed, it's just so weird

Ok, I like "so weird" more than "really really bad". :)

Ali



More information about the Digitalmars-d-learn mailing list