Safer casts

Dee Girl deegirl at noreply.com
Tue May 13 01:42:37 PDT 2008


Yigal Chripun Wrote:

> 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).

But no language I know can pass the nested function by alias. Pass by alias is fundamental different from pass by delegate. I have tried to explain it all this time. Do we agree on this now?

> side note: I heard Walter doesn't like anything that looks or smells
> like pascal.

Then I am sure he wish Pascal did not have nested functions ^_^ PS I installed spell check for English on emacs now, at least fewer typos! Thank you, Dee Girl 




More information about the Digitalmars-d mailing list