Created
November 26, 2010 09:09
-
-
Save runeb/716439 to your computer and use it in GitHub Desktop.
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
# An attempt at visualising classbox local rebinding as described in | |
# http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.3.4133&rep=rep1&type=pdf | |
# | |
# Suppose a classbox ClassBox1 defines a class C with two methods, m callin n, and | |
# classbox ClassBox2 imports C from ClassBox1 and replaces n. We say that… | |
class C;end | |
module ClassBox1 | |
refine C do | |
def m | |
n | |
end | |
def n | |
'ClassBox1' | |
end | |
end | |
end | |
module ClassBox2 | |
using ClassBox1 | |
refine C do | |
def n | |
'ClassBox2' | |
end | |
end | |
end | |
# …ClassBox2 locally rebinds n in ClassBox1 to represent the fact that calling m in the | |
# context of ClassBox2 invokes the method n as defined in ClassBox2 while calling m in | |
# the context of ClassBox1 invokes the method n as it is defined in ClassBox1. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment