On Sep 26, 2008, at 5:32 PM, Hallvord R. M. Steen wrote:

On Fri, 26 Sep 2008 19:58:27 +0200, liorean <[EMAIL PROTECTED]> wrote:

2008/9/26 Erik Arvidsson <[EMAIL PROTECTED]>:
I know that Opera on mobile phones used to return a string
representation that did not reflect the original.

Yeah. Opera Mobile returned "[ECMAScript code]" or "[ecmascript
code]". This was contrary to the ES3 spec (must be parsable as a
function definition, IIRC) and also breaks the eval roundtripping by
throwing a parse error.
Anybody know if those issues have been fixed in more modern versions?

No, not consistently across "modern versions". It's not likely to be
properly "fixed" for a while yet. The reason is that on many platforms
where memory is scarce, not enabling JS decompilation helps reduce memory
requirements.

Unfortunately several major libraries (prototype in particular, jQuery to a minor extent) have started (ab)using decompilation for various purposes.
Pages that rely on this tend to malfunction in Opera on low-memory
devices. Some Opera versions make at least some of these pages work again by returning "function(){[ecmascript code]}" instead but that's of course
a silly hack..

(It would be great if ES-next could have a look at why these libraries
rely on toString - hacks and make it possible to do equivalent things with nicer language constructs. One of the reasons toString is used is probably
outside the group's scope and caused by typeOf bugs in IE: prototype's
isFunction method uses toString in order to reliably detect whether
something is a function reference. Another usage is apparently - from my

That's what jQuery's `isFunction` used to do. Afaik, they reverted it to a simple `instanceof` check just recently. In prototype.js, on the other hand, we tried to work around cross-frame "issues" that arise when using `instanceof`. Doing a `typeof` check (of both an object and its call property) seems to be sufficient.


memory - to look at the names of the named arguments and do something
magic if the first argument is $super. I'm not up-to-date on whether the
next iteration has an elegant solution for this apparent requirement.)

Latest build does the same thing. That "something magic" is actually just creating a reference to a "super" method (same-named method of a parent class). Function decompilation, while non-standard, seems to be the best solution when implementing such inheritance mechanism. We would gladly consider alternative (more compliant) solutions, if any exist.



--
Hallvord R. M. Steen
Core QA JavaScript tester, Opera Software
http://www.opera.com/
Opera - simply the best Internet experience
_______________________________________________
Es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

--
Juriy Zaytsev

_______________________________________________
Es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to