Thanks to visit codestin.com
Credit goes to github.com

Skip to content

1464 bound static methods#1573

Merged
jashkenas merged 2 commits into
jashkenas:masterfrom
geraldalewis:1464_bound_static_methods
Aug 5, 2011
Merged

1464 bound static methods#1573
jashkenas merged 2 commits into
jashkenas:masterfrom
geraldalewis:1464_bound_static_methods

Conversation

@geraldalewis

Copy link
Copy Markdown
Contributor

Issue #1464 Static fat functions don't keep context
Opened by: @maccman
Date opened: June 24, 2011
Milestone: 1.2

Given the input:

class C then @static: =>

... currently compiles to:

var C;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
C = (function() {
  function C() {
    this.C = __bind(this.C, this);
  }
  C.static = function() {};
  return C;
})();

note that static is not bound to C, and C is bound to itself.
This patch produces the following output:

var C;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
C = (function() {
  function C() {}
  C.static = __bind(function() {}, C);
  return C;
}).call(this);

static is now properly bound to C.

jashkenas added a commit that referenced this pull request Aug 5, 2011
@jashkenas jashkenas merged commit 4e71aad into jashkenas:master Aug 5, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants