Why are interfaces so restrictive?

BCS BCS_member at pathlink.com
Sat Mar 18 13:46:58 PST 2006


In article <dvht07$g9u$1 at digitaldaemon.com>, Jarrett Billingsley says...
>
>"BCS" <BCS_member at pathlink.com> wrote in message 
>news:dvhh1e$318k$1 at digitaldaemon.com...
>>>> [#1] the class has to have access to the local stack frame 
>>>> (by storing a pointer to it and adding another level of 
>>>> indirection)
>> Yep, I agree that would work, however that is method #1 from above, and 
>> the access to the array is by way of a pointer stored in the object.
>
>And how else would you access that array?  How would it be done with your 
>method?  Your method really just looks like a class. 
>

In the case described, the interface has a context pointer that points to an
object, in that object is a pointer to the stack frame of the function that is
used to get the array. What I am proposing would be to have the interfaces
context pointer point to the stack frame directly.

(*(*Object.ptr).frame).array

vs.

(*frame).array

The difference is much like the difference between a delegate made from a class
method call and one from a nested function call.

Yes, they look a lot alike, but one is a little bit more expensive.





More information about the Digitalmars-d mailing list