Separate dynamic object arrays for multiple instances of overlying object

Timon Gehr timon.gehr at gmx.ch
Sat Mar 16 13:47:42 UTC 2024


On 3/14/24 15:44, Matheus wrote:
> On Thursday, 14 March 2024 at 12:00:37 UTC, Basile B. wrote:
>> On Thursday, 14 March 2024 at 10:21:41 UTC, Jonathan wrote:
>>> The following seems the be the minimum required for this problem to 
>>> pop up.  I've changed the names to what I'm using in my code to make 
>>> it more clear for me.
>>>
>>> [...]
>>
>> Classic. Instead of a static initializer rather uses a constructor for 
>> instances.
>>
>> ```d
>> class Spectrum
>> {
>>     PrecursorList precursorList;
>>     this()
>>     {
>>         precursorList = new PrecursorList();
>>     }
>> }
>> ```
> 
> I wonder how it would be if we had an error or warning for something 
> like this. For example displaying a message forcing the use of the word 
> "static" and initialize with "static this" when expecting static 
> initialization or construct for new instances.
> 
> Before someone points out: https://dlang.org/spec/class.html
> 
> Yes I know, but unfortunately this mistake as Basile noted as "classic", 
> is very common.
> 
> Matheus.

Well, I guess I can still point out that this is what OpenD does:
https://github.com/opendlang/opend/pull/8


More information about the Digitalmars-d mailing list