www.digitalmars.com         C & C++   DMDScript  

D - Delegate restrictions

reply "Matt Green" <matt somewhere.net> writes:
I notice on the delegates page of the D site it reads:
"Delegates cannot be initialized with static member functions or non-member
functions."

Why is this? Does this mean I have to choose between them in my code? I'd
hate to be the one to make the choice whether a particular callback works
with only methods or only free functions. I can see that delegates not
supposed to replace function pointers, but there needs to be a way to accept
either a function pointer or a delegate.

Regards,
Matt
Dec 02 2003
parent "Julio CÚsar Carrascal Urquijo" <adnoctum phreaker.net> writes:
Yes, you have to choose. Walter is working on unifying function and delegate
syntax but for now you have to use either function() or delegate()

"Matt Green" <matt somewhere.net> wrote in message
news:bqj5f0$90m$1 digitaldaemon.com...
 I notice on the delegates page of the D site it reads:
 "Delegates cannot be initialized with static member functions or

 functions."

 Why is this? Does this mean I have to choose between them in my code? I'd
 hate to be the one to make the choice whether a particular callback works
 with only methods or only free functions. I can see that delegates not
 supposed to replace function pointers, but there needs to be a way to

 either a function pointer or a delegate.

 Regards,
 Matt

Dec 02 2003