Re: appending newly initialized struct to array

2012-04-18 Thread Kenji Hara
On Wednesday, 18 April 2012 at 04:55:23 UTC, Ali Çehreli wrote: On 04/17/2012 02:00 PM, simendsjo wrote: Sounds like a bug. C style initializers work in other cases: I try not to use them. I think they have this 'feature' of leaving unspecified members uninitialized: struct S { int i;

Re: appending newly initialized struct to array

2012-04-18 Thread Somedude
Le 18/04/2012 12:41, maarten van damme a écrit : That's a very odd design. Making it work when instantiating a new struct of that type but not inline. Anyway, test(3,5) works perfect, thank you. It's not odd at all. You append a structure, not an array. {3,5} is for array initialization, it's

Re: appending newly initialized struct to array

2012-04-18 Thread Ali Çehreli
On 04/18/2012 12:16 AM, Kenji Hara wrote: On Wednesday, 18 April 2012 at 04:55:23 UTC, Ali Çehreli wrote: assert(s.d == double.nan); // -- fails (may work for you) You should use std.math.isNaN whether a floating point value is NaN. assert(isNaN(s.d)); // -- success That a thousandth

Re: appending newly initialized struct to array

2012-04-18 Thread bearophile
Ali: That a thousandth time I have made that mistake and still have not learned. :( Yes, .nan may not be compared with any other value, including .nan. Today I'll present an enhancement request to remove this problem from D. Hugs, bearophile

Re: appending newly initialized struct to array

2012-04-18 Thread SomeDude
On Wednesday, 18 April 2012 at 16:36:39 UTC, bearophile wrote: Ali: That a thousandth time I have made that mistake and still have not learned. :( Yes, .nan may not be compared with any other value, including .nan. Today I'll present an enhancement request to remove this problem from D.

Re: appending newly initialized struct to array

2012-04-18 Thread Jonathan M Davis
On Wednesday, April 18, 2012 19:04:12 SomeDude wrote: On Wednesday, 18 April 2012 at 16:36:39 UTC, bearophile wrote: Ali: That a thousandth time I have made that mistake and still have not learned. :( Yes, .nan may not be compared with any other value, including .nan. Today I'll

Re: appending newly initialized struct to array

2012-04-18 Thread SomeDude
On Wednesday, 18 April 2012 at 18:18:44 UTC, Ali Çehreli wrote: On 04/18/2012 10:13 AM, Jonathan M Davis wrote: It's by design. An enhancement request is a waste of time. Comparisons with NaN _always_ return false regardless of what they're compared against - even NaN. It's not going to

Re: appending newly initialized struct to array

2012-04-18 Thread H. S. Teoh
On Wed, Apr 18, 2012 at 08:50:10PM +0200, SomeDude wrote: On Wednesday, 18 April 2012 at 18:18:44 UTC, Ali Çehreli wrote: On 04/18/2012 10:13 AM, Jonathan M Davis wrote: It's by design. An enhancement request is a waste of time. Comparisons with NaN _always_ return false regardless of what

Re: appending newly initialized struct to array

2012-04-18 Thread bearophile
SomeDude: It shouldn't be a problem to detect comparisons against literal .nan values. The compiler can warn with comparison is always false. Ali Now THAT makes sense. That's what my proposal is going to be, with small refinements :-) (And it think it's not the first time someone

Re: appending newly initialized struct to array

2012-04-18 Thread Jonathan M Davis
On Wednesday, April 18, 2012 11:18:44 Ali Çehreli wrote: On 04/18/2012 10:13 AM, Jonathan M Davis wrote: On Wednesday, April 18, 2012 19:04:12 SomeDude wrote: On Wednesday, 18 April 2012 at 16:36:39 UTC, bearophile wrote: Ali: That a thousandth time I have made that mistake and still have

appending newly initialized struct to array

2012-04-17 Thread maarten van damme
Just for fun I decided to complete some codejam challenges in D. At some point I wanted to add structs to an array but I got a compiler error. What am I doing wrong? code: struct test{ int x; int y; } void main(){ test[] why; why~={3,5}; } error: wait.d(7): found '}' when expecting ';' following

Re: appending newly initialized struct to array

2012-04-17 Thread H. S. Teoh
On Tue, Apr 17, 2012 at 10:28:31PM +0200, maarten van damme wrote: Just for fun I decided to complete some codejam challenges in D. At some point I wanted to add structs to an array but I got a compiler error. What am I doing wrong? code: struct test{ int x; int y; } void main(){

Re: appending newly initialized struct to array

2012-04-17 Thread simendsjo
On Tue, 17 Apr 2012 22:28:31 +0200, maarten van damme maartenvd1...@gmail.com wrote: Just for fun I decided to complete some codejam challenges in D. At some point I wanted to add structs to an array but I got a compiler error. What am I doing wrong? code: struct test{ int x; int y; }

Re: appending newly initialized struct to array

2012-04-17 Thread bearophile
simendsjo: Sounds like a bug. C style initializers work in other cases: D language is so much irregular, so many special cases that don't work :-) Bye, bearophile

Re: appending newly initialized struct to array

2012-04-17 Thread Kenji Hara
On Tuesday, 17 April 2012 at 21:00:55 UTC, simendsjo wrote: On Tue, 17 Apr 2012 22:28:31 +0200, maarten van damme maartenvd1...@gmail.com wrote: Just for fun I decided to complete some codejam challenges in D. At some point I wanted to add structs to an array but I got a compiler error. What

Re: appending newly initialized struct to array

2012-04-17 Thread Ali Çehreli
On 04/17/2012 02:00 PM, simendsjo wrote: Sounds like a bug. C style initializers work in other cases: I try not to use them. I think they have this 'feature' of leaving unspecified members uninitialized: struct S { int i; double d; } void main() { S s = { 42 }; //