Created
December 12, 2010 12:36
-
-
Save anttih/738010 to your computer and use it in GitHub Desktop.
Modules in Io (closure problem)
This file contains hidden or 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
# 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