Re: struct variable initialized with void.

2015-04-01 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 31 March 2015 at 16:24:02 UTC, John Colvin wrote: On Tuesday, 31 March 2015 at 16:10:07 UTC, Adam D. Ruppe wrote: On Tuesday, 31 March 2015 at 15:59:53 UTC, John Colvin wrote: Like almost never? I can't think of any reason to ever do that. I mentioned it because of this story: ht

Re: struct variable initialized with void.

2015-03-31 Thread ref2401 via Digitalmars-d-learn
Thank you.

Re: struct variable initialized with void.

2015-03-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/31/15 11:23 AM, Adam D. Ruppe wrote: On Tuesday, 31 March 2015 at 15:12:54 UTC, ref2401 wrote: Could anyone describe me what this initialization does, please? It skips the initialization entirely, leaving the memory random instead of making it zeroes (or NaN or whatever the .init is of th

Re: struct variable initialized with void.

2015-03-31 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Mar 31, 2015 at 03:23:11PM +, Adam D. Ruppe via Digitalmars-d-learn wrote: [...] > 3) You are initializing a private member with default construction > turned off. Here, "Struct s;" wouldn't compile because of the disabled > default constructor, but you need to set it up anyway. So you

Re: struct variable initialized with void.

2015-03-31 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 31 March 2015 at 16:10:07 UTC, Adam D. Ruppe wrote: On Tuesday, 31 March 2015 at 15:59:53 UTC, John Colvin wrote: Like almost never? I can't think of any reason to ever do that. I mentioned it because of this story: https://www.schneier.com/blog/archives/2008/05/random_number_b.ht

Re: struct variable initialized with void.

2015-03-31 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 31 March 2015 at 15:59:53 UTC, John Colvin wrote: Like almost never? I can't think of any reason to ever do that. I mentioned it because of this story: https://www.schneier.com/blog/archives/2008/05/random_number_b.html I'm sure there's better ways to do it, but since a similar t

Re: struct variable initialized with void.

2015-03-31 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 31 March 2015 at 15:23:12 UTC, Adam D. Ruppe wrote: 2) you want some kind of random data, like if you are using it to seed a random number. There's often better ways of doing this, but =void might work in some cases. Like almost never? I can't think of any reason to ever do that.

Re: struct variable initialized with void.

2015-03-31 Thread Lukasz Wrzosek via Digitalmars-d-learn
On Tuesday, 31 March 2015 at 15:12:54 UTC, ref2401 wrote: struct MyStruct { // stuff } void main(string[] args) { MyStruct s1 = void; } Could anyone describe me what this initialization does, please? When do I need to use the void initialization? By default variables are initi

Re: struct variable initialized with void.

2015-03-31 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 31 March 2015 at 15:12:54 UTC, ref2401 wrote: Could anyone describe me what this initialization does, please? It skips the initialization entirely, leaving the memory random instead of making it zeroes (or NaN or whatever the .init is of the actual type, typically zero though).