Nobody understands templates?

develop32 develop32 at gmail.com
Wed Mar 5 16:02:42 PST 2014


On Wednesday, 5 March 2014 at 23:47:33 UTC, H. S. Teoh wrote:
> Whoa. What did you do with those arrays?? Either you did 
> something
> wrong, or there's a nasty bug somewhere in the 
> compiler/language; AFAIK
> static arrays are supposed to be value types so they shouldn't 
> generate
> any garbage at all.

I think it was the case of using array literals, like this (I 
didn't know much about D back then)

this(float x, float y, float z)
{
    this.vector = [x, y, z];
}

And megabytes accumulated because there were hundreds of objects 
all doing complicated stuff every frame, passing and constructing 
vectors and matrices around.

Memory leaks could have been avoided, but still, one should be 
careful when using arrays.



More information about the Digitalmars-d-learn mailing list