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

downs default_357-line at yahoo.de
Wed Oct 3 22:25:49 PDT 2007


Gregor Richards wrote:
> 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

Damn, you're right. How much of a problem is this?
Note that the cost only occurs if the delegate actually uses outside
variables.
 --downs



More information about the Digitalmars-d mailing list