Using closure in function scope to make "real" private class members

bauss jj_1337 at live.dk
Wed Jun 8 09:58:22 UTC 2022


On Wednesday, 8 June 2022 at 09:55:00 UTC, bauss wrote:
> On Wednesday, 8 June 2022 at 09:38:24 UTC, Ola Fosheim Grøstad 
> wrote:
>> On Wednesday, 8 June 2022 at 09:34:09 UTC, forkit wrote:
>>> Walter has his firm view. I have mine.
>>
>> Sure, your viewpoint would make sense for D3, but then there 
>> would be many such adjustments to make.
>>
>> To make all those adjustments in D2 with no breaking change 
>> would @lead @to @a @mess.
>
> Not in this case. I already proposed something that can work 
> without providing attribute soup.
>
> Just extend the private access modifier to allow an optional 
> specifier such as class/struct.
>
> https://forum.dlang.org/post/wmamhwkfdqgzaqndgaus@forum.dlang.org
>
> Ex.
>
> ```
> class Foo
> {
>   private int a; // private to module
>   private class int b; // private to class
> }
> ```

Could also be like this instead:

```
class Foo
{
   private int a; // private to module
   private this int b; // private to class
}
```

Thinking about it using this instead of class/struct is probably 
better, since it doesn't make sense to restrict to anything else 
other than itself.


More information about the Digitalmars-d mailing list