Re: Why is "array operation without destination memory not allowed"?

2018-01-06 Thread Lily via Digitalmars-d-learn
On Saturday, 6 January 2018 at 23:17:53 UTC, Ali Çehreli wrote: So, apparently a[] * 2 is not an expression in D. The reason must be for performance. If a[]*2 were an expression, the runtime would have to allocate memory and put the results there. Assigning that memory then to b[] would

Why is "array operation without destination memory not allowed"?

2018-01-06 Thread Lily via Digitalmars-d-learn
It seems a bit silly that I have to write int[] a = [1, 2, 300, -29]; int[] b; b.length = 4; b[] = a[] * 2; writeln(b); to do what I would expect int[] a = [1, 2, 300, -29]; writeln(a[] * 2); to do. What am I not understanding?

Help optimizing code?

2018-01-01 Thread Lily via Digitalmars-d-learn
I started learning D a few days ago, coming from some very basic C++ knowledge, and I'd like some help getting a program to run faster. The code is here: https://github.com/IndigoLily/D-mandelbrot/blob/master/mandelbrot.d Right now it runs slower than my JavaScript Mandelbrot renderer on the