ES6 and Error Object properties
Brendan Eich
brendan at mozilla.com
Wed Nov 4 13:27:43 PST 2009
On Nov 4, 2009, at 12:39 PM, P T Withington wrote:
> On 2009-11-04, at 15:28, Brendan Eich wrote:
>
>> On Nov 4, 2009, at 12:26 PM, Brendan Eich wrote:
>>
>>> SpiderMonkey, when you set the JSOPTION_ATLINE runtime option
>>> flag, understands a comment of this form:
>>
>> //@line n
>>
>> //@line n "f"
>
> Can I enable this option from my script (preferably, or Firebug as a
> second choice)?
Alas not in content script. It seems the original bug that depended
on //@line infrastructure (which is in SpiderMonkey, ready to be
used), the bug to enable //@line *only* for our browser UI ("chrome")
and similar such (XBL, XPCOM component) scripts, has stalled:
https://bugzilla.mozilla.org/show_bug.cgi?id=246286
I will get this bug going again, including the ability to set
_options.atline = true;
in the first <script> in a document, in order to get //@line support
in the rest of the scripts.
Yes, we have runtime option reflection. Try this URL in Firefox's
address bar:
javascript:alert(uneval(_options))
and you should see
({strict:false, werror:false, relimit:false})
The strict option pre-dates ES5 (and ES4/ES3.1) strict mode by many
years, and enables strict *warnings*. Many of these matched the ES5
strict mode *errors* (good taste!) so we have reconciled the two
systems, with one exception I know of (we do not give a strict warning
if you use 'with' statements).
The werror option, inspired by GCC's option of the same name, turns
warnings into errors.
The relimit option, if true, limits regexp complexity to O(n^3) in
order to throw exceptions at all-to-easy-to-write exponentially
complex regexps. The limit works by bounding the number of
backtracking steps to the cube of the target string length or 400000,
whichever is larger.
You can assign to these properties, although there's a bug noted here:
https://bugzilla.mozilla.org/show_bug.cgi?id=452451#c1
which prevents you from seeing relimit set to true -- but it does in
fact get set by assignment if you evaluate
_options.relimit = true;
I'll probably fix this soon.
> I'm happy to adopt this syntax as being as good as any other.
It is a candidate, but it is modeled after the C pre-processor, always
a warning sign! I will write a wiki-spec for it and throw it into
strawman:.
/be
More information about the es-discuss
mailing list