adding bound functions, with test

This commit is contained in:
Jeremy Ashkenas
2010-01-13 20:59:57 -05:00
parent 0ceca0778c
commit 1e7d638435
10 changed files with 87 additions and 76 deletions

View File

@@ -0,0 +1,22 @@
x: 1
y: {}
y.x: => 3
print(x is 1)
print(typeof(y.x) is 'function')
print(y.x() is 3)
print(y.x.name is 'x')
obj: {
name: "Fred"
bound: =>
(==> print(this.name is "Fred"))()
unbound: =>
(=> print(!this.name?))()
}
obj.unbound()
obj.bound()