Posts

Showing posts with the label Strict

Object.defineProperty ... but Strict!

In my precedent post entitled A Pascal record via JavaScript I have showed a basic function able to emulate type hints behavior via JavaScript. Even if that was a proof of concept, I consider other languages simulation of unsupported features an error, first of all because the behavior will rarely be exactly the expected one, secondly because our curent programming language may already have something similar to better learn and use. A new ES5( direction ) As soon as I have written the Pascal example, I have realized that the good "old" Object.defineProperty , implemented in all major browsers (IE The only missing part, intrinsic in the JavaScript nature, is the property type, where this type could be eventually used for arguments or returns checks when the property is a method. My Early Attempts Back in May 2007, my JavaStrict experiment was already trying to do something similar, something implemented after 2 years even in dojo framework as well. This may tell us that ...

[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...

[PHP] Strict error on static call? Solved!

Just a quick post about Strict standard error when we have a class method which would like to behave differently if called statically. Apparently, and this is a truly old bogus I opened ages ago , the solution was to supress Strict errors (lol, thanks developers) even if in every other programming language, via overload, this kind of situation could be solved in a bit. How to solve the problem? While last post I suggested a couple of runtime solutions, this time I suggest to simply avoid the method definition and use a different one with a meaningful name. In this example I created a String class: class String { // choose a recognizable name for protected method static protected function _concat(array $arguments){ return new self(implode('', $arguments)); } // use magic __callStatic function static public function __callStatic($name, array $arguments){ // check the recognizable name switch($name = '_'.$name){ ...