Adding a new design constraint to D

The Zealot zod at zod.zod
Tue Jun 14 16:49:13 UTC 2022


On Tuesday, 14 June 2022 at 16:33:10 UTC, Max Samukha wrote:
> On Tuesday, 14 June 2022 at 13:49:30 UTC, Ola Fosheim Grøstad 
> wrote:
>
>>
>> It isn't necessarily through a different path unless you think 
>> that Bar is cloaking Foo, basically redoing everything that is 
>> Foo.
>
> D encourages me to think about it as being similar to 'alias 
> this', which seems to behave differently:
>
> ```d
> module a;
>
> import b;
>
> struct Foo
> {
>     private int _c;
> }
>
> void foo(Bar b)
> {
>     b._c = 1; // passes, to Mike's and my surprise
> }
>
> void main()
> {
> }
> ```
> ```d
> module b;
>
> import a;
>
> struct Bar
> {
>     Foo foo;
>     alias foo this;
> }
> ```

that looks like a bug too


More information about the Digitalmars-d mailing list