Message from JavaScript discussions

December 2017

— Meh, maybe I can make a new sysCallProcedures class that accepts a thisArg as an argument to the constructor

Message permanent page

— 

Then at least I don't have to create a ton of new functions, and also I don't have to use apply or call in my logic (just inside the class)

— Correct

— 

Kernel.prototype.sysCallInterface.someCall

gets routed to
Kernel.prototype.sysCall(call)

which calls
Kernel.prototype.sysCallProcedures.someCall

Message permanent page

— 

Kernel.sysCallInterface.someCall("data");

returns
["someCall", ["data"]]

so
Kernel.sysCall(["someCall", ["data"]]);

calls
Kernel.sysCallProcedures.someCall

Message permanent page

— But I don't want to create new functions on each kernel instance

— Hm, why does this not work well?

Object.keys(tests).reduce(
(acc, name) =>
acc[name] = tests[name].bind(this),
{}
);

Message permanent page

— Gets me a weird result

— 

var t = new testClass();
t.boundTests
ƒ () {
console.log(this.thing);
}

— Welp it's frustrating to see reduce not work, haha

— Went with this instead of reduce:

Object.keys(tests).forEach(
name =>
this.boundTests[name] = tests[name].bind(this)
);

Message permanent page

— I was missing rest operator somewhere but at that point forEach is simpler