Re: delegates with C linkage

2010-06-05 Thread Zarathustra
For starters, your first delegate is declared in an extern(C) block, meaning it has C linkage. The second is declared outside of the block, meaning it has D linkage. So they are two different types of delegates. What is the difference? Secondly, I'm not sure if you can pass delegates to a C

Re: delegates with C linkage

2010-06-05 Thread dennis luehring
Am 05.06.2010 13:33, schrieb Zarathustra: Secondly, I'm not sure if you can pass delegates to a C function. C code wouldn't understand delegates. They are not the same as function pointers. I suggest you use function pointers instead, paying attention to linkage. Of course It is possible,

Re: delegates with C linkage

2010-06-05 Thread Zarathustra
only with static methods - a real delegate needs the this-pointer in a register (not on the stack), thats the main difference between function ptr and delegates, thats why you can't use a (non static) method on for example the win-api callbacks, because the caller don't know your object gcc:

Re: delegates with C linkage

2010-06-05 Thread dennis luehring
Am 05.06.2010 15:42, schrieb Zarathustra: only with static methods - a real delegate needs the this-pointer in a register (not on the stack), thats the main difference between function ptr and delegates, thats why you can't use a (non static) method on for example the win-api callbacks,

Re: delegates with C linkage

2010-06-05 Thread dennis luehring
Am 05.06.2010 16:03, schrieb dennis luehring: Am 05.06.2010 15:42, schrieb Zarathustra: only with static methods - a real delegate needs the this-pointer in a register (not on the stack), thats the main difference between function ptr and delegates, thats why you can't use a (non static)

Re: noob Q: declaring string variables

2010-06-05 Thread Nick Sabalausky
Jesse Phillips jessekphillip...@gmail.com wrote in message news:htue1b$2so...@digitalmars.com... D1.x has an alias for string to char[] Phobos does, but Tango doesn't seem to.

Re: delegates with C linkage

2010-06-05 Thread Zarathustra
but that will help on the caller side (you using gcc?) but D still won't accept an delegat in an extern C because this type does not exists in the C world Maybe it is the reason but the error message is still nonsense. btw: can show us code where you do this and it works - why don't you use

foreach AA key char[] type change

2010-06-05 Thread bearophile
Do you know why this D2 program prints const(char)[] instead of char[] ? import std.stdio: writeln; void main() { int[char[]] data = [cast(char[])foo : 1]; foreach (key, val; data) writeln(typeid(typeof(key))); } Bye and thank you, bearophile

Re: foreach AA key char[] type change

2010-06-05 Thread Steven Schveighoffer
On Sat, 05 Jun 2010 20:42:43 -0400, bearophile bearophileh...@lycos.com wrote: Do you know why this D2 program prints const(char)[] instead of char[] ? import std.stdio: writeln; void main() { int[char[]] data = [cast(char[])foo : 1]; foreach (key, val; data)