Tennent’s Principle of Correspondence

The first of which was Tennent’s Principle of Correspondence. In my research I’ve found two different explanations of it. First from Neal Gafter’s Blog: “The principle dictates that an expression or statement, when wrapped in a closure and then immediately invoked, ought to have the same meaning as it did before being wrapped in a closure.”

console.log("Printed!");(function(){console.log("Printed!");}());

Second from Techscursion, “for any parameter mechanism, an analogous definition mechanism is possible, and vice versa.”

This and Return

There’s a few sort of wonky workarounds you have to manage in certain situations. Yehuda Katz covers the issues around this and return in his article JavaScript Needs Blocks. You can see how I had to handle them in my Tennentive version, extra returns and binding this to a parameter.

Function.prototype.curry=function(){//Extra return to pass on return of anonymous functionreturn(function(args,fn){returnfunction(){//Extra return to pass on return of anonymous functionreturn(function(innerArgs,context){returnfn.apply(context,args.concat(innerArgs));})(Array.prototype.slice.call(arguments),this);//Bind this to an argument}})(Array.prototype.slice.call(arguments),this);//Bind this to an argument}