Newbie initial comments on D language - delegate

BCS ao at pathlink.com
Mon Jan 28 20:08:05 PST 2008


Reply to Edward,

> As I was reading about delegates and the syntax to initialize them I
> was thinking that such similar natural syntax had been suggested to
> C++ many times over the years. Of course delegates already have their
> antecedents in C++ Builder closures and .Net delegates among others.
> My reaction to delegates and their elegant syntax was "bravo, of
> course" but I also had the reaction of why are there both 'delegate'
> and 'function'.
> 
> Later in the pdf documentation I saw the a note that the future might
> see 'delegate' and 'function' folded into a single callable type. My
> reaction to this is: ABSOLUTELY NECESSARY. In fact I think it is a
> mistake to have divided callables into two types. The 'function'
> should have been dropped and a 'delegate' should have been
> initializable from any sort of callable in D, including class member
> function, class non-member functions ( static member functions ),
> global functions, nested functions, and any other callable in D I
> might have missed.

The issue I see is that delegates are 64 bits (assuming a 32bit system) and 
functions are 32 bits. To maintain link compatibility with C, the 32bit plain-old-function-pointer 
form is needed. But it can't (cleanly) be used with delegates that need that 
extra 32bits for the context/this pointer.





More information about the Digitalmars-d mailing list