Thread overview
Q: Delegate Literal in Class Member
May 18, 2004
Russ Lewis
Re: Delegate Literal in Class Member
May 19, 2004
Walter
May 19, 2004
Russ Lewis
May 20, 2004
Walter
May 18, 2004
In this code, is the delegate literal a stack delegate (i.e. the builtin ptr points to the stack frame), or a class delegate (i.e. the builting ptr points to 'this')?  If the former, is there some way to make it a class delegate?

class Foo {
  void delegate() GetDelegate() {
    return delegate void() {
             return fooFunc(3);
    };
  }

  void fooFunc(int x) { ... }
}

If the delegate literal is a stack delegate, then I can't return it (since the stack frame goes away).  But if it's a class delegate, then I can return it from the function and let it be called later from any stack.

May 19, 2004
A class delegate can only be formed from a class member function.

"Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message news:c8dof9$1vuf$1@digitaldaemon.com...
> In this code, is the delegate literal a stack delegate (i.e. the builtin ptr points to the stack frame), or a class delegate (i.e. the builting ptr points to 'this')?  If the former, is there some way to make it a class delegate?
>
> class Foo {
>    void delegate() GetDelegate() {
>      return delegate void() {
>               return fooFunc(3);
>      };
>    }
>
>    void fooFunc(int x) { ... }
> }
>
> If the delegate literal is a stack delegate, then I can't return it (since the stack frame goes away).  But if it's a class delegate, then I can return it from the function and let it be called later from any stack.
>


May 19, 2004
I'm confused.  Isn't that exactly what's going on here?  Or are you saying that a class delegate can only be formed with the syntax:
	<var>.memberFuncName
?

Walter wrote:
> A class delegate can only be formed from a class member function.
> 
> "Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message
> news:c8dof9$1vuf$1@digitaldaemon.com...
> 
>>In this code, is the delegate literal a stack delegate (i.e. the builtin
>>ptr points to the stack frame), or a class delegate (i.e. the builting
>>ptr points to 'this')?  If the former, is there some way to make it a
>>class delegate?
>>
>>class Foo {
>>   void delegate() GetDelegate() {
>>     return delegate void() {
>>              return fooFunc(3);
>>     };
>>   }
>>
>>   void fooFunc(int x) { ... }
>>}
>>
>>If the delegate literal is a stack delegate, then I can't return it
>>(since the stack frame goes away).  But if it's a class delegate, then I
>>can return it from the function and let it be called later from any stack.
>>
> 
> 
> 

May 20, 2004
No, you've created a delegate literal, which is a nested function. Try instead &member.

"Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message news:c8gkai$d42$1@digitaldaemon.com...
> I'm confused.  Isn't that exactly what's going on here?  Or are you
> saying that a class delegate can only be formed with the syntax:
> <var>.memberFuncName
> ?
>
> Walter wrote:
> > A class delegate can only be formed from a class member function.
> >
> > "Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message news:c8dof9$1vuf$1@digitaldaemon.com...
> >
> >>In this code, is the delegate literal a stack delegate (i.e. the builtin ptr points to the stack frame), or a class delegate (i.e. the builting ptr points to 'this')?  If the former, is there some way to make it a class delegate?
> >>
> >>class Foo {
> >>   void delegate() GetDelegate() {
> >>     return delegate void() {
> >>              return fooFunc(3);
> >>     };
> >>   }
> >>
> >>   void fooFunc(int x) { ... }
> >>}
> >>
> >>If the delegate literal is a stack delegate, then I can't return it (since the stack frame goes away).  But if it's a class delegate, then I can return it from the function and let it be called later from any
stack.
> >>
> >
> >
> >
>