"use subset" introductory material
brendan at mozilla.org
Mon Jun 30 23:31:08 PDT 2008
On Jun 30, 2008, at 9:08 PM, Mark S. Miller wrote:
> On Mon, Jun 30, 2008 at 7:37 PM, Maciej Stachowiak <mjs at apple.com>
>> JSON be handled with a generic subset mechanism? I expect not,
>> since a
>> pragma inside the JSON source in the form of an initial quoted
>> string would
>> be (a) invalid JSON and (b) ineffective as a way to validate
>> incoming JSON,
>> since malicious alleged JSON would not use such a pragma.
> Whether or not it's a good idea, given "use subset JSON" as a
> recognized/enforced subset directive, one could trivially implement
> JSON.stringify(str) in terms of
> eval('"use subset JSON"; (' + str + ')')
That's nothing like how JSON parsing is implemented in Mozilla. If
the idea is to add a mode to the ES parser, then I'm worried about
missed exclusion tests and false economies in a hacked up JS parser
trying to serve two (or more) masters.
JSON is defined by http://www.ietf.org/rfc/rfc4627.txt -- not by
ES1-3 or any future spec. It's a "subset" of Python and other
languages -- it's more accurately its own language. It's better off
with ts own parser implementation, unit tests, etc. -- browsers want
this for application/json handling anyway (no pragma or restrictive
API mode required).
Given that JSON.stringify is a proposed extension in ES3.1 (and was
slated to be in ES4, after we rejected the old json.org API), why
does the above trivial (except for possibly non-trivial risks in
subsetting a real JS parser) re-implementation via eval matter?
>> I do think JSON should be supported natively, but it does not seem
>> at all
>> analogous to strict mode / cautious subset.
> I think I agree. In any case, I agree that JSON is not by itself a
> compelling case for "use subset X". My point is only that JSON is a
> huge counter-example to Brendan's statement that "profiled (subsetted)
> standards are meaningless to harmful on the web".
JSON is not huge, and that's one point in favor of keeping it
separate from ES futures. It is not defined as a subset in any ES spec.
It's also not an intentional, new-in-the-last-month, paper-spec-only
written, he "discovered" it. Inventing new, multiple, as-yet-unused
subsets for ES3.1 -- and not implementing any of them in any
experimental-to-beta released browser, especially not in IE8 -- is a
bad idea. It will cause general and widespread opposition to any
attempt to standardize such a ES3.1 this year.
At least OOXML and E4X (to name two Ecma standards of mixed repute)
each had one implementation -- however buggy or deficient some have
argued those specs and their single implementations were. ES3.1 has
none, not even a buggy work-in-progress reference implementation.
My point is to recall the original "ES3 + reality" anti-mission-creep
goal for ES3, which you among others espoused. Right now it's on a
road to completion at the same time frame as a cut-down ES4, which
will make for a busy 2009 -- assuming its supporters actually
demonstrate it in several testable, interoperating implementations.
> JSON was defined as
> helpful to the web.
Except where people used JS parsers naively. Which is one variation
on a theme that you are still playing in advocating "use subset JSON".
More information about the Es4-discuss