C# does closures by creating a class. When you run the function, captured local variables actually live inside the object instead of in the stack. This makes use of an object, but no memory pages need to become read/write/executable to make C#-style closures happen. You just have a combination function/object pointer (a delegate) instead of a single function pointer.
Question isn't how can a function closure be represented anywhere, but how it can be represented in a way that can be aliased by a vanilla C function-pointer, which is a more specific and challenging question.
Comments
need to represent the "captured-variables"/closure
C# does closures by creating a class. When you run the function, captured local variables actually live inside the object instead of in the stack. This makes use of an object, but no memory pages need to become read/write/executable to make C#-style closures happen. You just have a combination function/object pointer (a delegate) instead of a single function pointer.
Question isn't how can a function closure be represented anywhere, but how it can be represented in a way that can be aliased by a vanilla C function-pointer, which is a more specific and challenging question.