How Nested Functions Work, part 1
Edward Diener
eddielee_no_spam_here at tropicsoft.com
Wed Sep 2 21:27:34 PDT 2009
Jarrett Billingsley wrote:
> On Wed, Sep 2, 2009 at 9:45 AM, Andrei
> Alexandrescu<SeeWebsiteForEmail at erdani.org> wrote:
>> Jarrett Billingsley wrote:
>>> Well repeat should probably always take a delegate since most likely,
>>> you're going to be passing it a lambda. However I agree that it would
>>> be very, very nice to be able to make APIs take just delegates and
>>> allow functions to be implicitly cast to them. You can already make
>>> your own thunks, but they're not going to be as efficient as something
>>> that actually works on an ABI level.
>> Did someone file a bug report on this?
>
> Surprisingly, it doesn't seem like it. Walter himself, in the spec,
> said that "Function pointers and delegates may merge into a common
> syntax and be interchangeable with each other," so I just assume that
> no one has found it necessary to make a report. Maybe there should be.
I suggested this a long time back on this NG, and I am sure many others
have also. A function pointer should essentially be a delegate whose
object is null. That is essentially the way delegates are in .Net. In
C++, boost::Function can encompass any C++ callable type so there is
little theoretical reason why D should not encompass all callable types
into a delegate. Having to program for any callable type, in a
functional callable or signal/slots library, by dealing with the two
signature variations of a function pointer and a delegate rather than a
single common signature is a real PITA in an advanced programming language.
More information about the Digitalmars-d
mailing list