ctfe: .idup on static array and static variables

2009-12-13 Thread Lutger
i have two question related to ctfe: 1) returning .idup on local static arrays fail but I don't understand why that should be: string foo() { char[1] d; d[0] = 'd'; return d.idup; } pragma(msg, foo()); // "Error: cannot evaluate foo() at compile time" .idup is not mentioned in th

Re: Implicit conversion from array of class to array of interface

2009-12-13 Thread Phil Deets
On Sun, 13 Dec 2009 04:08:19 -0500, Phil Deets wrote: I found another workaround which doesn't require a bunch of extra overloads. I'll probably update it to use that template someone wrote in that thread about static duck-typing. I looked up this post. It was: "Re: static interface" by Si

Re: Implicit conversion from array of class to array of interface

2009-12-13 Thread Phil Deets
On Sun, 13 Dec 2009 04:16:19 -0500, Frank Benoit wrote: casting an array of class references to an array of interface references (or vice versa) will not work at runtime. Your program will crash. This is because if the invisible pointer correction that is done if you cast a single class ref

Re: Implicit conversion from array of class to array of interface

2009-12-13 Thread Frank Benoit
casting an array of class references to an array of interface references (or vice versa) will not work at runtime. Your program will crash. This is because if the invisible pointer correction that is done if you cast a single class ref to an interface ref. C c = new C; I i = c; writefln( "c=%d

Re: Implicit conversion from array of class to array of interface

2009-12-13 Thread Phil Deets
On Sun, 13 Dec 2009 03:22:31 -0500, Phil Deets wrote: (D 2.033) I have a need to do something like this code: interface I {} class C : I {} class D : I {} void f(I[]) {} void f(bool) {} void g(T)(T param) { f(param); } int main() { bool b; C[] c; D[] d;

Implicit conversion from array of class to array of interface

2009-12-13 Thread Phil Deets
(D 2.033) I have a need to do something like this code: interface I {} class C : I {} class D : I {} void f(I[]) {} void f(bool) {} void g(T)(T param) { f(param); } int main() { bool b; C[] c; D[] d; g(b); g(c); g(d); return 0; }