Separate dynamic object arrays for multiple instances of overlying object
Matheus
matheus at gmail.com
Thu Mar 14 14:44:45 UTC 2024
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.
More information about the Digitalmars-d
mailing list