Re: Is `void` the correct way to say "do not initialize this variable"?

2022-10-06 Thread kdevel via Digitalmars-d-learn
On Monday, 3 October 2022 at 15:56:02 UTC, Paul Backus wrote: Shouldn't this read Unspecified Value: If a void initialized variable's value is used before it is set, its value is unspecified. Yes, it should. Many of the contributors to the D spec are not very well versed in the

Re: Is `void` the correct way to say "do not initialize this variable"?

2022-10-03 Thread Paul Backus via Digitalmars-d-learn
On Monday, 3 October 2022 at 14:37:35 UTC, kdevel wrote: On Sunday, 2 October 2022 at 23:37:26 UTC, ryuukk_ wrote: I got the answer thanks to IRC chat: https://dlang.org/spec/declaration.html#void_init Quote: Implementation Defined: If a void initialized variable's value is used

Re: Is `void` the correct way to say "do not initialize this variable"?

2022-10-03 Thread kdevel via Digitalmars-d-learn
On Sunday, 2 October 2022 at 23:37:26 UTC, ryuukk_ wrote: I got the answer thanks to IRC chat: https://dlang.org/spec/declaration.html#void_init Quote: Implementation Defined: If a void initialized variable's value is used before it is set, its value is implementation defined.

Re: Is `void` the correct way to say "do not initialize this variable"?

2022-10-03 Thread drug007 via Digitalmars-d-learn
On 10/3/22 09:35, tsbockman wrote: On Sunday, 2 October 2022 at 23:45:45 UTC, drug007 wrote: It works but not as someone could expect. In case of ```D Foo[2] arr = void; ``` `arr` value is not defined, it is not an initialized array of uninitialized elements like you want, it is just

Re: Is `void` the correct way to say "do not initialize this variable"?

2022-10-03 Thread tsbockman via Digitalmars-d-learn
On Sunday, 2 October 2022 at 23:30:16 UTC, ryuukk_ wrote: ```D MyStruct test = void; ``` Does this guarantee that the compiler will not initialize it? It's more of a request, than a guarantee. For example, `= void` may be ignored for the fields of `struct`s and `class`es: ```D struct ABC {

Re: Is `void` the correct way to say "do not initialize this variable"?

2022-10-03 Thread tsbockman via Digitalmars-d-learn
On Sunday, 2 October 2022 at 23:45:45 UTC, drug007 wrote: It works but not as someone could expect. In case of ```D Foo[2] arr = void; ``` `arr` value is not defined, it is not an initialized array of uninitialized elements like you want, it is just uninitialized array. This is incorrect. It

Re: Is `void` the correct way to say "do not initialize this variable"?

2022-10-02 Thread drug007 via Digitalmars-d-learn
On 10/3/22 02:30, ryuukk_ wrote: I have tried to look at the documentation and various places on the DMD source, but i couldn't find the answer https://dlang.org/spec/declaration.html#void_init ```D MyStruct test = void; ``` Does this guarantee that the compiler will not initialize it?

Re: Is `void` the correct way to say "do not initialize this variable"?

2022-10-02 Thread ryuukk_ via Digitalmars-d-learn
I got the answer thanks to IRC chat: https://dlang.org/spec/declaration.html#void_init

Is `void` the correct way to say "do not initialize this variable"?

2022-10-02 Thread ryuukk_ via Digitalmars-d-learn
I have tried to look at the documentation and various places on the DMD source, but i couldn't find the answer ```D MyStruct test = void; ``` Does this guarantee that the compiler will not initialize it? Does it work with static arrays of struct too? The generated code is different than