logoalt Hacker News

mwkaufmayesterday at 6:22 PM1 replyview on HN

need to represent the "captured-variables"/closure


Replies

Dwedittoday at 4:43 AM

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.