Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# __get_binding_of_caller and __run_code is a compiler hack to invoke VM
# instructions directly.
class Closure:
def construct(code):
let @code = code
let @binding = __get_binding_of_caller(_)
pub def call(args...):
__run_code(_, @code, args, @binding)
# Once the full namespace ("core::closure::Closure") exists this can be
# converted to just:
#
# let closure = ->: STDOUT.puts("yay closure")
#
# Right now the namespace doesn't exist so the below syntax has to be used.
let closure = Closure.new: STDOUT.puts("yay closures")
closure.call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.