Please fix `.init` property

Hipreme msnmancini at hotmail.com
Mon Jan 8 13:25:50 UTC 2024


On Monday, 8 January 2024 at 11:53:52 UTC, Bastiaan Veelo wrote:
> On Sunday, 7 January 2024 at 23:12:30 UTC, Hipreme wrote:
>> ```d
>> struct MyTest
>> {
>>     string[] dirs = ["source"];
>> }
>> ```
>
> I have argued that initializers of non-static members that 
> allocate should be an error [1]. Mike and Steven agree [2, 3].
>
> [1] 
> https://forum.dlang.org/post/ogvubzgprghefclgluce@forum.dlang.org
> [2] 
> https://forum.dlang.org/post/wvrasioewzbqrqsufwxd@forum.dlang.org
> [3] https://forum.dlang.org/post/t7vm2o$p4q$1@digitalmars.com
>
> I will add pointers to 
> https://issues.dlang.org/show_bug.cgi?id=24324.
>
> -- Bastiaan.


I have 2 thoughts on how it could be solved:

- Make it an error
- Make a copy of a shared instance

Currently, the solution for that is doing a copy of a shared 
instance anyway. If it impacts the performance, that is on the 
user. Having this erratic behavior is the only thing that can't 
continue. I've lost a plenty of time in a big project.

And no, almost no one has the entire spec in mind. Even more to 
getting those particular behaviors. The spec can be precise, but 
it doesn't mean it is correct to work like that.
People will continue falling on the same stone, early or late.


More information about the Digitalmars-d mailing list