Created
July 26, 2022 17:54
-
-
Save cpurdy/4cc33bdc969044a96f911a473a2cdef3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module TestSimple | |
{ | |
@Inject Console console; | |
void run() | |
{ | |
function Int() f = makeMeAClosure(); | |
console.println($"after losing the stack frame, the returned closure evaluates to {f()}"); | |
} | |
function Int() makeMeAClosure() | |
{ | |
Int x = 10; | |
Int y = 20; | |
function Int() closure = () -> x + y; | |
console.println($"before changing x and y, the closure evaluates to {closure()}"); | |
x = 42; | |
y = 42; | |
console.println($"after changing x and y, the closure evaluates to {closure()}"); | |
return closure; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment