Skip to content

Instantly share code, notes, and snippets.

@anttih
Created December 12, 2010 12:36
Show Gist options
  • Save anttih/738010 to your computer and use it in GitHub Desktop.
Save anttih/738010 to your computer and use it in GitHub Desktop.
Modules in Io (closure problem)
# I'd like the inner object's methods to have access to Module's `inside` slot.
# The new lexicalDo won't cut it since the proto is long gone when the
# block/method gets called.
Module := Object clone do(
inside := 2
Test := Object clone lexicalDo(
num := method(inside)
numblock := block(inside) setIsActivatable(true)
)
Another := Object clone
Another numblock := block(inside) setIsActivatable(true)
)
test := Module Test clone
# neither works
test num println
test numblock println
a := Module Another clone
# works
a numblock println
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment