Re: Cannot convert of type HANDLE to HANDLE

2009-09-09 Thread Sam Hu
Ary Borenszweig Wrote: > FQN = Fully Qualified Name Got it.Thanks!

Re: How does D cope with aliasing

2009-09-09 Thread #ponce
> If you always want DMD never to bounds check for specific code, you just > can write "a.ptr[index]" instead of "a[index]" (when a is an array). > That's because array.ptr returns a pointer to the first element, and > using [] on a pointer works exactly like C pointer math. The good thing > ab

Re: delegate reference

2009-09-09 Thread Saaa
>> Or does the compiler handle them like any >> other >> function and just thinks of a name itself ? > > Exactly. If you compile with DMD and the -v flag you can see what names it > gives them. :) nice Thanks!

Re: delegate reference

2009-09-09 Thread BCS
Hello Saaa, Hello Saaa, How should I do this then? C c; C2 c2 = new C2; C3 c3 = new C3; c=c2; auto dg = { return c.method(); }; c=c3; I actually did it like this before :) Thanks But like this I need to do the "c is null" checking within the function literal. I'm not sure how these functi

Re: delegate reference

2009-09-09 Thread Saaa
> Hello Saaa, > >> How should I do this then? > > C c; > C2 c2 = new C2; > C3 c3 = new C3; > c=c2; > > auto dg = { return c.method(); }; > > c=c3; I actually did it like this before :) Thanks But like this I need to do the "c is null" checking within the function literal. I'm not sure how these

Re: How does D cope with aliasing

2009-09-09 Thread grauzone
#ponce wrote: Stewart Gordon Wrote: My recollection of reading the spec is that a D compiler is allowed to optimise by assuming no pointer aliasing. But I can't remember at the moment where I read this. I don't know if this is neat or nasty for a compiler to do so. OT : Is there a DMD swi

Re: delegate reference

2009-09-09 Thread BCS
Hello Saaa, How should I do this then? C c; C2 c2 = new C2; C3 c3 = new C3; c=c2; auto dg = { return c.method(); }; c=c3;

Re: delegate reference

2009-09-09 Thread BCS
Hello Saaa, "Daniel Keep" wrote in message news:h88i4n$235...@digitalmars.com... Saaa wrote: "Daniel Keep" wrote in message news:h88cck$1or...@digitalmars.com... Saaa wrote: abstract class C { int method(); } class C2:C { int method() return 2; } class C3:C { int method() return 3; } i

Re: delegate reference

2009-09-09 Thread Saaa
> > class Foo > { > C* c; > > this(ref C c) > { >this.c = &c; > } > > int invoke() > { >return (*c).method(); > } > } > > void main() > { > // ... > deleg = &(new Foo(c)).invoke; > } > > Or something similar. > > This is dangerous. Do not allow either the Foo instance or the deleg

Re: delegate reference

2009-09-09 Thread Daniel Keep
Saaa wrote: > Ok, disregard my last comment :D > How should I do this then? class Foo { C* c; this(ref C c) { this.c = &c; } int invoke() { return (*c).method(); } } void main() { // ... deleg = &(new Foo(c)).invoke; } Or something similar. This is dangerous. Do n

Re: delegate reference

2009-09-09 Thread Saaa
"Daniel Keep" wrote in message news:h88i4n$235...@digitalmars.com... > > > Saaa wrote: >> "Daniel Keep" wrote in message >> news:h88cck$1or...@digitalmars.com... >>> >>> Saaa wrote: abstract class C { int method(); } class C2:C { int method() return 2;

Re: delegate reference

2009-09-09 Thread Saaa
"Ary Borenszweig" wrote in message news:h88i6o$23h...@digitalmars.com... > Saaa wrote: >> "Daniel Keep" wrote in message >> news:h88cck$1or...@digitalmars.com... >>> >>> Saaa wrote: abstract class C { int method(); } class C2:C { int method() return 2;

Re: delegate reference

2009-09-09 Thread Ary Borenszweig
Saaa wrote: "Daniel Keep" wrote in message news:h88cck$1or...@digitalmars.com... Saaa wrote: abstract class C { int method(); } class C2:C { int method() return 2; } class C3:C { int method() return 3; } int delegate() deleg; void main() { C c; C2 c2 = new C2; C3 c3 = new C3; c=c2; c

Re: delegate reference

2009-09-09 Thread Daniel Keep
Saaa wrote: > "Daniel Keep" wrote in message > news:h88cck$1or...@digitalmars.com... >> >> Saaa wrote: >>> abstract class C >>> { >>> int method(); >>> } >>> class C2:C >>> { >>> int method() return 2; >>> } >>> class C3:C >>> { >>> int method() return 3; >>> } >>> int delegate() deleg; >>>

Re: delegate reference

2009-09-09 Thread Saaa
"Daniel Keep" wrote in message news:h88cck$1or...@digitalmars.com... > > > Saaa wrote: >> abstract class C >> { >> int method(); >> } >> class C2:C >> { >> int method() return 2; >> } >> class C3:C >> { >> int method() return 3; >> } >> int delegate() deleg; >> void main() >> { >> C c; >> C

Re: delegate reference

2009-09-09 Thread Daniel Keep
Saaa wrote: > abstract class C > { > int method(); > } > class C2:C > { > int method() return 2; > } > class C3:C > { > int method() return 3; > } > int delegate() deleg; > void main() > { > C c; > C2 c2 = new C2; > C3 c3 = new C3; > c=c2; > deleg = &c.method; > writefln(deleg()); // 2 >

delegate reference

2009-09-09 Thread Saaa
abstract class C { int method(); } class C2:C { int method() return 2; } class C3:C { int method() return 3; } int delegate() deleg; void main() { C c; C2 c2 = new C2; C3 c3 = new C3; c=c2; deleg = &c.method; writefln(deleg()); // 2 c=c3; writefln(deleg()); // 2 // I expected this to wr

Re: Cannot convert of type HANDLE to HANDLE

2009-09-09 Thread Ary Borenszweig
Sam Hu escribió: div0 Wrote: You must have two different HANDLEs around. The one in phobos is aliased to void* and there is no LoadLibraryEx call in phobos, so you must be using something else. Try using the FQN of the import where you are getting the LoadLibraryEx from. Thanks for your help.