-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Classes (for TS at least) #68
Comments
FYI: LiveScript classes look like the following: class A
-> console.log \hello
x: (y) -> 2 * y
t: ~> 2 * t
...and compiles to the following Javascript: var A;
A = (function(){
A.displayName = 'A';
var prototype = A.prototype, constructor = A;
function A(){
this.t = bind$(this, 't', prototype);
console.log('hello');
}
A.prototype.x = function(y){
return 2 * y;
};
A.prototype.t = function(){
return 2 * t;
};
return A;
}());
function bind$(obj, key, target){
return function(){ return (target || obj)[key].apply(obj, arguments) };
} |
if we get |
What if we made Functions be Objects? |
(that would let us have the first thing @eclipticccc suggested) |
Here is how i see it: make functions have an internal field, lets say |
@pitust it already kind of works like that there are actually 3 things:
|
Maybe, but code like: function f() {}
f.a = 3; doesn't work. function __real_f() {}
var f = {};
f.__internal_fnptr_call = __real_f;
f.a = 3; |
ah I see. there's a difference between |
Classes shouldn't be too difficult to get working, especially in typescript, and should be even easier than prototypes (i think).
The text was updated successfully, but these errors were encountered: