Postblit not called in one case

2011-07-05 Thread bearophile
With DMD 2.053 the second assert of this program fires, is this a DMD bug or it's me that's missing something? struct Foo { int[] data; this(int n) { data.length = n; } this(this) { data = data.dup; } } void main() { Foo f1, f2; f1 = Foo(1); f2 =

Hashing protocol

2011-07-05 Thread bearophile
Since some time the built-in associative arrays don't use search trees to manage collisions, but just linked lists. So if you want to implement the hash protocol for a struct do you need to add it a opCmp() too still (that was needed just for those trees), or is now opEquals() enough (plus toHas

Re: swap doesn't work in CTFE?

2011-07-05 Thread Johann MacDonagh
On 7/4/2011 10:39 PM, Daniel Murphy wrote: "bearophile" wrote in message news:iut093$1bjg$1...@digitalmars.com... Daniel Murphy: Same thing happens with pointers. Reduced: Pointers to structs in CTFE will work in DMD 2.054 :-) When they don't crash the compiler, that is. http://d.puremag

Re: swap doesn't work in CTFE?

2011-07-05 Thread Jonathan M Davis
On 2011-07-05 12:10, Ary Manzana wrote: > On 7/4/11 11:39 PM, Daniel Murphy wrote: > > "bearophile" wrote in message > > news:iut093$1bjg$1...@digitalmars.com... > > > >> Daniel Murphy: > >>> Same thing happens with pointers. Reduced: > >> Pointers to structs in CTFE will work in DMD 2.054 :-) >

Re: swap doesn't work in CTFE?

2011-07-05 Thread Ary Manzana
On 7/4/11 11:39 PM, Daniel Murphy wrote: "bearophile" wrote in message news:iut093$1bjg$1...@digitalmars.com... Daniel Murphy: Same thing happens with pointers. Reduced: Pointers to structs in CTFE will work in DMD 2.054 :-) When they don't crash the compiler, that is. http://d.puremagic

Re: Dynamic multidimensional arrays

2011-07-05 Thread Jonathan M Davis
On 2011-07-05 11:29, Trass3r wrote: > > If you want it to by dynamic all the way, you need to put > > the dimensions in the parens like above. Personally, I _never_ put them > > in the brackets, even when the dynamic array has just one dimension. > > It's just > > simpler to always put them in the

Re: Dynamic multidimensional arrays

2011-07-05 Thread Trass3r
If you want it to by dynamic all the way, you need to put the dimensions in the parens like above. Personally, I _never_ put them in the brackets, even when the dynamic array has just one dimension. It's just simpler to always put them in the parens and not worry about it. Maybe we should f

Re: Dynamic multidimensional arrays

2011-07-05 Thread Bellum
On 7/5/2011 2:00 AM, Jonathan M Davis wrote: On 2011-07-04 23:56, Jonathan M Davis wrote: On 2011-07-04 23:42, Bellum wrote: Can anyone point me in the right direction for doing something like this in D: char[][] anArray; int rows, cols; ... anArray = new char[rows][c

Re: Operator Overloading and boilerplate code

2011-07-05 Thread Loopback
On 2011-07-05 18:05, Ali Çehreli wrote: I don't want to look like brushing off the problem but having many constructors make the code complicated. For example, it may be confusing which constructor gets called here: auto d = DVECTOR2(1.5); That might be true. I just did what felt most con

Re: Operator Overloading and boilerplate code

2011-07-05 Thread Ali Çehreli
On Tue, 05 Jul 2011 16:20:44 +0200, Loopback wrote: > On 2011-07-05 03:11, Ali Çehreli wrote: >> struct S >> { >> this(T)(double d) >> {} >> } >> >> void main() >> { >> auto o = S(1.5); >> } >> >> Error: template deneme.S.__ctor(T) does not match any function template >> declaratio

Re: Operator Overloading and boilerplate code

2011-07-05 Thread Loopback
On 2011-07-05 03:11, Ali Çehreli wrote: On Tue, 05 Jul 2011 02:44:03 +0200, Loopback wrote: I've researched a bit though I still haven't come up with a solution. Since the problem lies within (the most simple) constructor, I tried to modify it for another outcome. If I supplied a generic parame

Re: Using a C function with command line parameters

2011-07-05 Thread Steven Schveighoffer
On Tue, 05 Jul 2011 00:29:14 -0400, Jonathan Sternberg wrote: It's one of the applications that consumes command line arguments. So if I wanted to implement this, a copy of the D strings (and null terminated) would have to be made. I would also likely need to add another slot to the comman

Re: void.sizeof == 1, not 0

2011-07-05 Thread simendsjo
On 01.07.2011 22:18, Ali Çehreli wrote: On Fri, 01 Jul 2011 21:18:45 +0200, simendsjo wrote: What is contained within this byte? (T[0]).sizeof == 0, why isn't void also 0? void* can point to any data, in which case it is considered to be pointing at the first byte of the data. Having a size o

Re: Dynamic multidimensional arrays

2011-07-05 Thread bearophile
Jonathan M Davis Wrote: > It quickly gets confusing when dealing with dimensions and static arrays IMHO. I agree. I have raised this topic time ago with no results so far. I find it surprising that Walter & Andrei too don't think of this as confusing :-| Bye, bearophile

Re: Dynamic multidimensional arrays

2011-07-05 Thread Jonathan M Davis
On 2011-07-04 23:56, Jonathan M Davis wrote: > On 2011-07-04 23:42, Bellum wrote: > > Can anyone point me in the right direction for doing something like this > > > > in D: > > char[][] anArray; > > int rows, cols; > > > > ... > > > > anArray = new char[rows][cols];