bearophile wrote:
Saaa:

Is there a better way to support arrays of any type?
Currently all the code working with these Structs are templated with loads of static ifs in them.

You have to ask a more precise question if you want an answer.


Also, is it possible to add a .deepdup property to all arrays?

D devs don't read posts here, so you have to ask ask in the main newsgroup. I 
have asked for that more than a year ago, and I was ignored, as usual.

You always seem to be so negative! In one recent DMD release, half the changes were bugfixes requested by you...

If everyone involved in compiler development spent 100% of their time on bearophile requests, you still might not get everything you want <g>. Actually you have at least 20% of my time. Stop complaining, and start prioritizing...



Will "a[]=b.dup;" copy b twice?

When you have questions like this it's good to take a look at the produced asm.
The dup allocates a new array and then copies data on it.
The a[]=b[]; copies b on a.


int[] array;
array.length = 100;
array.length = 0;
//no other arrays pointing/slicing to this array
This way I can be sure for the following 100 element concatenations
the array won't be copied.
Or isn't this implicitly part of the D spec?

Are you talking about appends or concatenations? Concatenations produce memory 
allocations. But you probably mean 100 appends. Those 100 appends will not 
produce allocations or copies.
But generally array appends are slow anyway in D, so where you need to do them 
quickly it's much better to use an ArrayBuilder like the one in my dlibs, of a 
similar one a bit less efficient in Phobos of D2.

Bye,
bearophile

Reply via email to