Safer casts
Yigal Chripun
yigal100 at gmail.com
Tue May 13 01:29:08 PDT 2008
Dee Girl wrote:
>> foo _is_ a delegate. there is no difference: As I explained in a
>> different post, a delegate is simply two pointers where the context
>> pointer either points to the surrounding function for nested
>> functions or to the this pointer for methods.
>
> It is clear what is a delegate. It is pointer to a function and
> pointer to environment. Like in Lisp.
exactly what I've said.
>
> But foo is not delegate. It is nested function. Like in Pascal. If
> you call foo from the same scope there is regular function call. Not
> delegate call! If you take address &foo it becomes delegate. (I just
> checked). D has very interesting scheme. I hope Walter writes here
> and confirms. But your explanation is wrong. I hope you are not
> offended. I am sorry, Dee Girl
>
sure. Call it what you like, the point is that you can pass foo to a
function the same way you can pass a class method. so it's a nested
function that is automagically becomes a delegate by the compiler.
the functionality is the same.
for simplicity sake let me call it a delegate. now that we put the
terminology differences aside, we both agree about the behavior of this
D feature.
>From what I know many languages behave exactly like this (turning nested
functions into delegates).
side note: I heard Walter doesn't like anything that looks or smells
like pascal.
More information about the Digitalmars-d
mailing list