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

Gregor Richards Richards at codu.org
Wed Oct 3 22:17:31 PDT 2007


downs wrote:
> Gregor Richards wrote:
>> Downside #2: Calculating that range requires at best n pointer lookups
>> where n is the depth of the delegate. Creating delegates right now is free.
>>
>>  - Gregor Richards
> I believe that most delegates have a depth of one, so this isn't much of
> a problem. Alternatively, just set the array pointer to null initially
> and have the compiler fill it in when requested.
> 
>  --downs

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.

  - Gregor Richards



More information about the Digitalmars-d mailing list