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

ProtectAndHide ProtectAndHide at gmail.com
Sat Feb 18 21:37:28 UTC 2023


On Saturday, 18 February 2023 at 21:23:24 UTC, ProtectAndHide 
wrote:
>

Here is (one example) of the change I would like to see in D:

if private is declared against a member inside a class (or 
struct), then that member is visible only inside that class or 
struct. That is what most programmers in the world would expect. 
(most, not all).

if you want open access to that class, from other code in the 
same module, you mark that class (or struct) as open.

e.g

class foo
{
  private int x; // visible in this class only

}

open class bar
{
  private int y; // visible throughout the module - the same as it 
currently works.
}

so all you'd have to do, is mark your class (or struct) as open, 
and then anyone reading your code will immediately know that 
other code in the module may form part of the specification of 
this class.

so simple.




More information about the Digitalmars-d-learn mailing list