Re: Mixin on a bunch of foreach fails.

2012-01-12 Thread Timon Gehr
On 01/13/2012 05:07 AM, Charles McAnany (dlang) wrote: Hi, all. So I'm trying to make some very ugly code generic. The main ugliness isn't in the code shape, it's in the running time. It's O(n^m) Eww! (don't worry, n is only about 6.) Anyhoo, Here's what I want: void foo(int size)(int[] arr

Mixin on a bunch of foreach fails.

2012-01-12 Thread Charles McAnany (dlang)
Hi, all. So I'm trying to make some very ugly code generic. The main ugliness isn't in the code shape, it's in the running time. It's O(n^m) Eww! (don't worry, n is only about 6.) Anyhoo, Here's what I want: void foo(int size)(int[] arr){ mixin(forStart!(size)); doStuff(

opApply with/without ref

2012-01-12 Thread H. S. Teoh
Hi all, I'm experimenting with overloading foreach() with opApply, and I found that this code doesn't compile: class C { void opApply(int delegate(uint n) cb) const { ... } } unittest { auto c = new C;

Re: About implicit array cast

2012-01-12 Thread bearophile
Timon Gehr: > This is a bug. OK: http://d.puremagic.com/issues/show_bug.cgi?id=7285 Bye, bearophile

Re: About implicit array cast

2012-01-12 Thread Timon Gehr
On 01/13/2012 02:19 AM, bearophile wrote: This code compiles, because the [0,0] dynamic array literal casts implicitly to int[2]: int[2] foo() { return [0, 0]; // OK } void main() {} And of course this too compiles: int[2] bar() { int[2] ab; return (true) ? ab : ab; // OK }

About implicit array cast

2012-01-12 Thread bearophile
This code compiles, because the [0,0] dynamic array literal casts implicitly to int[2]: int[2] foo() { return [0, 0]; // OK } void main() {} And of course this too compiles: int[2] bar() { int[2] ab; return (true) ? ab : ab; // OK } void main() {} But currently this code doesn