I would like to generate functions in a loop:
for own k, v in t
ctor::[k] = ->
v(...)
@
However, coco seems to generate just one function and reuse it:
var k, v, __ref, __own = {}.hasOwnProperty;
for (k in __ref = t) if (__own.call(__ref, k)) {
v = __ref[k];
ctor.prototype[k] = __fn;
}
function __fn(){
v.apply(this, arguments);
return this;
}
How to change the coco script to make the output following:
var k, v, __ref, __own = {}.hasOwnProperty;
for (k in __ref = t) if (__own.call(__ref, k)) {
v = __ref[k];
ctor.prototype[k] = function() {
v.apply(this, arguments);
return this;
}
}
CLARIFICATION: With coco I mean this language: http://satyr.github.com/coco/ (a coffeescript fork).