Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Retiring JavaScript versions

137 views
Skip to first unread message

David Bruant

unread,
May 1, 2013, 8:05:11 AM5/1/13
to JS Internals list
Hi,

I've been thinking about Dave Herman's comment one the generator bug [1]
for a couple of days. Specifically:
"The explicit versioning is Mozilla-specific, and is basically a failed
experiment; the overwhelming majority of the web doesn't use it. The
HTML5 zeitgeist and the "One JavaScript" (1JS) movement, meanwhile, have
moved away from opt-in versioning as an anti-pattern."

So maybe it is time to slowly remove Mozilla-specific versioning?

David

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=666399#c56

Brendan Eich

unread,
May 1, 2013, 11:13:51 AM5/1/13
to David Bruant, JS Internals list
We definitely should remove version= usage when we can. We could also
migrate any version=1.7 hold-outs to 1.8 as an intermediate step, if
that's worthwhile.

The only engine source files containing JSVERSION are

frontend/Parser.cpp
frontend/Parser.h
jsapi.cpp
jscntxt.cpp
jscntxt.h
jspubtd.h
jsscript.cpp
shell/js.cpp
vm/GlobalObject.cpp
vm/Keywords.h
vm/SelfHosting.cpp

If I'm not mistaken, the only actual version tests among these are

frontend/Parser.cpp: if (version == JSVERSION_1_7 && !forEach &&
!forOf) {
frontend/Parser.cpp: if (version == JSVERSION_1_7 && !forEach &&
!forOf)
frontend/Parser.cpp: if (versionNumber() == JSVERSION_1_7) {
frontend/Parser.cpp: if (versionNumber() != JSVERSION_ECMA_3) {
frontend/Parser.cpp: if (versionNumber() == JSVERSION_1_7 &&
frontend/Parser.h: return versionNumber() >= JSVERSION_1_6;

The last is to allow 'for each(...)' from E4X (ECMA-357). That's a
separately actionable cleanup item, which I think we could do now that
for-of is implemented.

This one from the middle of the grep output:

frontend/Parser.cpp: if (versionNumber() != JSVERSION_ECMA_3) {

is about a de-facto semicolon insertion rule that ES5 codified (ASI
after do-while). We should just do it unconditionally.

The rest are JS1.7 cruft, see this recurring comment:

// In JS 1.7 only, for (var [K, V] in EXPR) has a special meaning.

Here is where migrating away from JS1.7 and even from opt-in versioning
ASAP would help.

The only other version tests are to enable 'let' and 'yield' as
keywords. ES6 (1JS) proposes different and opt-in-free ways to handle
these. We could use two bugs and independent efforts.

/be
> _______________________________________________
> dev-tech-js-engine-internals mailing list
> dev-tech-js-en...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals

Brendan Eich

unread,
May 1, 2013, 11:23:51 AM5/1/13
to David Bruant, JS Internals list
As usual, we don't break without broadcasting warnings and giving
downstreams a decent interval to adapt.

The uses of opt-in versioning are pretty much all XUL-based stuff and
Mozilla-only content, much of which we host. Converting to 1JS requires
some engine work, but also careful reading and rewriting of the
dependent code. This is non-trivial; we could use some help.

Anyone have JS static analysis tools for rewriting? A long shot, but we
did this for C++ back in the day and JS analysis is all the rage now.

/be
0 new messages