Permalink
Browse files

add Function.prototype.bind

  • Loading branch information...
1 parent 6603cf0 commit 466f1ba00edc5d9d97eef74b4e6969c1546c8705 @marijnh marijnh committed Dec 22, 2010
Showing with 9 additions and 1 deletion.
  1. +9 −1 runtime.lisp
View
@@ -243,7 +243,15 @@
(argobj (apply (proc this) self (argobj-list args)))
(t (js-error :type-error "Second argument to Function.prototype.apply must be an array."))))
(.func "call" (self &rest args)
- (apply (proc this) self args)))))
+ (apply (proc this) self args))
+
+ (.func "bind" (self &rest args)
+ (let ((proc (proc this))
+ (arity (cached-lookup this "length")))
+ (build-func (lambda (this &rest args-inner)
+ (declare (ignore this))
+ (apply proc self (append args args-inner)))
+ (max 0 (- arity (length args)))))))))
(add-to-lib *stdlib*
(.constructor "Array" (&rest args)

0 comments on commit 466f1ba

Please sign in to comment.