first draft of mandatory parentheses around function definition param lists -- all tests pass

This commit is contained in:
Jeremy Ashkenas
2010-01-26 00:40:58 -05:00
parent 63b44a2b03
commit 460b3f6d8e
57 changed files with 1396 additions and 1561 deletions

View File

@@ -1,6 +1,6 @@
x: 1
y: {}
y.x: => 3
y.x: () => 3
print x is 1
print typeof(y.x) is 'function'
@@ -9,17 +9,17 @@ print y.x.name is 'x'
# The empty function should not cause a syntax error.
=>
() =>
obj: {
name: "Fred"
bound: =>
(==> print(this.name is "Fred"))()
bound: () =>
(() ==> print(this.name is "Fred"))()
unbound: =>
(=> print(!this.name?))()
unbound: () =>
(() => print(!this.name?))()
}
obj.unbound()
@@ -29,18 +29,18 @@ obj.bound()
# The named function should be cleared out before a call occurs:
# Python decorator style wrapper that memoizes any function
memoize: fn =>
memoize: (fn) =>
cache: {}
self: this
args... =>
(args...) =>
key: args.toString()
return cache[key] if cache[key]
cache[key] = fn.apply(self, args)
Math: {
Add: a, b => a + b
AnonymousAdd: (a, b => a + b)
FastAdd: memoize a, b => a + b
Add: (a, b) => a + b
AnonymousAdd: ((a, b) => a + b)
FastAdd: memoize (a, b) => a + b
}
print Math.Add(5, 5) is 10