views:

79

answers:

2

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

+2  A: 

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.

sgreeve
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).
dotnetdev
Yes, I believe the terms are synonymous in general, and at least in the context of C#.
sgreeve
See the other answer from @nobugz - it appears that "Execution Frame" can have different meaning in the context of some other languages, especially Python.
sgreeve
+1  A: 

"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
+1 for educating me. I love this site.
sgreeve