September 09, 2009 Re: delegate reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to 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;
|
September 09, 2009 Re: delegate reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to 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;
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 function literals are implemented; will the size of
the function
have any impact on speed? Or does the compiler handle them like any other
function and just thinks of a name itself ?
|
September 09, 2009 Re: delegate reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to Saaa | 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 function literals are implemented; will the > size of > the function > have any impact on speed? No more than with normal functions. > 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. |
September 09, 2009 Re: delegate reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to BCS |
>> 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!
|
Copyright © 1999-2021 by the D Language Foundation