Feature Request: Change the delegate type to void[] data instead of void *ptr.

Rioshin an'Harthen rharth75 at hotmail.com
Thu Oct 4 00:04:15 PDT 2007


"Gregor Richards" <Richards at codu.org> kirjoitti viestissä 
news:fe1t1b$kvn$1 at digitalmars.com...
> The delegate is created as soon as you do &foo. After that point, whatever 
> receives &foo doesn't know anything about it, so it doesn't know how many 
> pointers it would have to jump through to get the right depth. So, you'd 
> need to either accept that creating delegates incurs n cost (something 
> that's fine by me since n is actually a constant), or have a special 
> syntax for delegates which have the extra information.

I have a small proposal for the syntax of delegates storing the extra 
information.

Currently we define a delegate with something akin to

    R delegate(T) dg = &foo;

Now, we want a syntax for delegates storing the stack context for the 
superior functions. According to the quote above, this looks like a case of 
needing extra dereferencing when used, so should be visible in declaring the 
delegate and assigning to it. Thus, I came up with the following:

    R delegate(T) &dg = &&foo;

where the extra ampersands - kind of like in C(++) - show that there's 
another step or multiple steps to (de)reference. 




More information about the Digitalmars-d mailing list