recursive delegate declaration

kris foo at bar.com
Tue Jun 20 16:48:03 PDT 2006


Walter Bright wrote:
> kris wrote:
> 
>> I have a situation whereby a delegate should return an instance of 
>> itself, to enable call chaining. Here's my attempt, which compiles and 
>> appears to work with dmd 161:
> 
> 
> This is an old problem, going back to C. How do you declare a function 
> type that returns itself? The only way is with a cast and a typedef 
> (alias).


Hehe - yeah :)

The example given is fine for my own personal use, but I shouldn't 
expose that sort of thing as part of an API :)

The easy and clean remedy is to use an interface instead, but in this 
case I was hoping to expose something "lightweight" instead. Any ideas 
for a practical resolution?



More information about the Digitalmars-d mailing list