Can a member function return a delegate to itself?
BCS
BCS at pathlink.com
Wed May 23 11:02:40 PDT 2007
Gregor Richards wrote:
> BCS wrote:
>
>> as mentioned, the reason this isn't directly doable is that the type
>> is undefinable. However this is strictly a limitation of the D Syntax
>> and their is no problem with actually doing it if you can tell DMD
>> how. I have does this using typing tricks before:
>>
>>
>> struct S
>> {
>> S delegate(int,int) dg;
>> }
>>
>> struct O
>> {
>> int k;
>> S go(int i, int j)
>> {
>> O* o = new O
>> o.k = k+i+j;
>> S ret;
>> ret.dg = &o.go;
>> return ret;
>> }
>> }
>
>
> I just want to say that this method is brilliant. It's easy to read and
> understand on a high and low level, and does everything you need it to
> do with no questions asked. Bravo.
>
> - Gregor Richards
A simple thank you would suffice. <g> Your welcome.
More information about the Digitalmars-d
mailing list