www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Is T.init allowed?

reply Andrey Zherikov <andrey.zherikov gmail.com> writes:
Seems compiler allows custom nested type with `init` name:

```d
struct T
{
     struct init {}

     int b = 2;
}

void main()
{
     T t;
     writeln(t);        // T(2)
     //writeln(T.init); // Error: cannot pass type `init` as a 
function argument
}
```

Is it a compiler issue so this shouldn't be allowed?
If this is OK then how can I refer to an initial value of `T` 
(`T.init` doesn't work)?
Apr 29 2022
parent reply Dennis <dkorpel gmail.com> writes:
On Friday, 29 April 2022 at 11:30:49 UTC, Andrey Zherikov wrote:
 Is it a compiler issue so this shouldn't be allowed?
Members called `init` are in the process of being deprecated, see: https://github.com/dlang/dmd/pull/12512
Apr 29 2022
parent Andrey Zherikov <andrey.zherikov gmail.com> writes:
On Friday, 29 April 2022 at 12:05:35 UTC, Dennis wrote:
 On Friday, 29 April 2022 at 11:30:49 UTC, Andrey Zherikov wrote:
 Is it a compiler issue so this shouldn't be allowed?
Members called `init` are in the process of being deprecated, see: https://github.com/dlang/dmd/pull/12512
That's nice!
Apr 29 2022