5

In C#, what is an execution frame (also related to this I have heard of activation frame). IIRC it is a slot where method parameters go but cannot remember all of the details.

Thanks

razlebe
  • 7,134
  • 6
  • 42
  • 57
GurdeepS
  • 65,107
  • 109
  • 251
  • 387

2 Answers2

5

"Execution frame" is a term that is used in interpreted languages, Python in particular. That's a very different execution model from C#. The closest equivalent is a scope block in a C# method, a chunk of code that is is bracketed with curly braces. Although a Python execution frame could also extend to the body of a function, now it's equivalent to a stack frame in C#. Which is another term for an activation frame.

The C# compiler recognizes declarations that are local to a scope block in C#. The runtime doesn't, it only recognizes a stack frame that's active for the life of the entire method. The difference is trivially papered-over by the compiler by simply declaring the sum of all local variables in all scope blocks as the activation frame. That's a luxury that a Python interpreter cannot afford.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
3

I believe you're referring to a stack frame - in which case the answer is not specific to C# or indeed to any particular language, but rather to the platform that your program is executing on. From the Wikipedia article on the Call Stack:

A call stack is composed of stack frames (sometimes called activation records). These are machine dependent data structures containing subroutine state information. Each stack frame corresponds to a call to a subroutine which has not yet terminated with a return.

See also this answer to a previous question for an excellent description of the stack, including stack frames.

Community
  • 1
  • 1
razlebe
  • 7,134
  • 6
  • 42
  • 57
  • So is an execution frame the same as a stack frame? I've seen the terms used seperately but I mean the exec frame (I'm aware of stack frame). – GurdeepS Mar 06 '10 at 01:01
  • Yes, I believe the terms are synonymous in general, and at least in the context of C#. – razlebe Mar 06 '10 at 01:42
  • See the other answer from @nobugz - it appears that "Execution Frame" can have different meaning in the context of some other languages, especially Python. – razlebe Mar 07 '10 at 19:50