Thread overview
Re: array concatenation issue, more details
Re: array concatenation issue, it's a bug in dmd2.0x
Mar 18, 2008
Tobias Kieslich
Mar 18, 2008
bearophile
Mar 18, 2008
Tobias Kieslich
Mar 18, 2008
Tobias Kieslich
Mar 18, 2008
Sönke Ludwig
Mar 18, 2008
Tobias Kieslich
March 18, 2008
Hi,

	as confirmed by downs, myself and bearophile in the 'works in gdc-1.0'
thread this is a bug in D 2.0. Guess I get a bugtracker account.
Dooh! what a way to start to learn a language :P Just kidding, I like D
a lot, it's a neat language.

	-Tobias

On Tue, 18 Mar 2008, Tobias Kieslich wrote:
> Now, here it is where it gets weird. Dynamic arrays of static arrays:
> 
> 	int [2][] b =[[0,1],[2,3]];
> 	b ~= [[4,5]];  // fail, because concatenate [2u][] with [][1u]
> 	b ~= [4,5];    // success but wrong result as b holds now:
> 	// [[0 1] [2 3] [4 5] [0 0]]
> 
March 18, 2008
Tobias Kieslich Wrote:
> this is a bug in D 2.0. Guess I get a bugtracker account.
> Dooh! what a way to start to learn a language :P Just kidding, I like D
> a lot, it's a neat language.

Use D 1.x, it's much more used and more debugged :-)

Bye,
bearophile
March 18, 2008
hi,

	after some more thinking i figured I'm way to preoccupied with my
scipting language past. I am concatenating apples and oranges here, it
seems. So let's go again:

	int [2][] y = [[1,2],[3,4]];
	writefln("%s --- length: %d", y, y.length );
	//y = y ~ [[9,10]]; // fail because concatenate [2u][] with [][1u]
	//y = y ~ [9,10]; // success, but wrong result
	//y = y ~ cast (int [2]) [9,10]; // success, but wrong result
	y = y ~ cast (int [2][]) [[9,10]]; // success, right result

so a very properly casted array can be concatenated, however, I think
that this line should produce a proper result as well:
	y = y ~ cast (int [2]) [9,10]; // success, but wrong result

especially because the following fails as well:
	int [2][] y = [[1,2],[3,4]];
	int [2] yx = [40,50];
	y = y ~ yx; // success, but wrong result
	writefln("%s --- length: %d", y, y.length );
	// [[1 2] [3 4] [40 50] [-1075618328 134587053]] --- length: 4

	-Tobias
March 18, 2008
On Tue, 18 Mar 2008, bearophile wrote:

> Use D 1.x, it's much more used and more debugged :-)
yepp, well, I'm a Linux package maintainer, I have no problems running some less stable stuff.

I have more trouble in this case to find out what is the desired behaviour, if I have to cast etc., well newbie stuff actually :P

	-Tobias
March 18, 2008
Tobias Kieslich schrieb:
> hi,
> 
> 	after some more thinking i figured I'm way to preoccupied with my
> scipting language past. I am concatenating apples and oranges here, it
> seems. So let's go again:
> 
> 	int [2][] y = [[1,2],[3,4]];
> 	writefln("%s --- length: %d", y, y.length );
> 	//y = y ~ [[9,10]]; // fail because concatenate [2u][] with [][1u]
> 	//y = y ~ [9,10]; // success, but wrong result
> 	//y = y ~ cast (int [2]) [9,10]; // success, but wrong result
> 	y = y ~ cast (int [2][]) [[9,10]]; // success, right result
> 
> so a very properly casted array can be concatenated, however, I think
> that this line should produce a proper result as well:
> 	y = y ~ cast (int [2]) [9,10]; // success, but wrong result
> 
> especially because the following fails as well:
> 	int [2][] y = [[1,2],[3,4]];
> 	int [2] yx = [40,50];
> 	y = y ~ yx; // success, but wrong result
> 	writefln("%s --- length: %d", y, y.length );
> 	// [[1 2] [3 4] [40 50] [-1075618328 134587053]] --- length: 4
> 
> 	-Tobias

This sounds like it might be related to http://d.puremagic.com/issues/show_bug.cgi?id=1891

At least the output looks quite similar.
March 18, 2008
On Tue, 18 Mar 2008, Sönke Ludwig wrote:

> This sounds like it might be related to http://d.puremagic.com/issues/show_bug.cgi?id=1891

yes agreed, shame on me I searched for the wrong keywords,or misspelled them so I filed a duplicated bug :(

	-Tobias