Posts

Showing posts with the label callee

arguments, callee, call, and apply performances

We have dozens of best practices to improve performances. We also have common practices to accomplish daily tasks. This post is about the most used JavaScript ArrayLike Object, aka arguments , and its performances impact over basic tasks. Why arguments While it's natural for JavaScripters to use such "magic" variable, as arguments is, in many other languages everybody knows it does not come for free and it is rarely used. <?php function myFunc() { // function call for each execution // rarely seen in good PHP scripts $arguments = func_get_args(); } ?> One clear advantage in PHP, Python, and many others, is the possibility to define a default value for each argument. <?php class UserManager extends MyDAL { public function exists($user='unknown', $pass='') { return $this->fetch('SELECT 1 FROM table WHERE user=? AND pass=?', $user, $pass); } } ?> This approach may brings automatically developers to code as ...

ES5 arguments and callee, I was wrong!

JavaScript is not JavaScript, I am not crazy, it is just a consideration between the language itself and what is behind it: another programming language with lower level rules and logic ... sounds silly and obvious, but please keep reading to understand what I mean. No Results Yet, But I've Already Lost My Battle I spread comments, I wrote post after posts to defend ECMAScript 5 arguments.callee decision with "use strict", but I have to admit I have never investigate the internal behavior of callee, an arguments property which is not what we think is ... Discovering In Core The Callee Property What I was thinking was something hilarious for a C or C++ programmer: an inherited property for a mutable instance. // JavaScript should have a "secret" Arguments class // and for each function, something like this function Test(){}; // we have declared the function Test // internally there should be a secret operation like this: Test._createArguments = function(args){...

[ECMAScript 5] Do Not Remove arguments.callee !

Being subscribed in dunno how many developers mailing list, I completely forgot to follow up the arguments and arguments.callee discussion. Accordingly to this John post , is with extreme surprise that I am discovering how critical is the gap between programming language developers and programming languages active users. Even if I read more than once piece of SpiderMonkey or Google Chrome, I am part of programming languages users and I can tell you for sure that the decision to remove arguments.callee from the language will be a complete mess. The Main Aim Of ECMAScript 5: Do Not Break What We Have So Far Unfortunately, Internet Explorer will be broken , because named function persists in the scope , causing naming conflicts everywhere ! setTimeout(function f(){ alert(window.f); }, 1000); Above code will alert the function f in every Internet Explorer . Moreover, as you can read in one comme of John's entry, Internet Explorer has function interpretation "problems" , d...