For future reference when debugging inside JS modules (where no dump function is available)

Tags: , , , , , , , — Jeff @ 19:59
function dump(msg)
  var mod = {};
  Components.utils.import("resource://gre/modules/ctypes.jsm", mod);
  var ctypes = mod.ctypes;
  var libc = ctypes.open("libc.so.6");
  var puts =
    libc.declare("puts", ctypes.default_abi, ctypes.int, ctypes.char.ptr);
  puts("!!!!!!!!!!!!!!!!!!!\n" +
       "!!! " + msg + "\n" +


Incompatible ES5 change: literal getter and setter functions must now have exactly zero or one arguments

ECMAScript accessor syntax in SpiderMonkey

For quite some time SpiderMonkey and Mozilla-based browsers have supported user-defined getter and setter functions (collectively, accessors), both programmatically and syntactically. The syntaxes for accessors were once legion, but SpiderMonkey has pared them back almost to the syntax recently codified in ES5 (and added new syntax where required by ES5).

// All valid in ES5
var a = { get x() { } };
var b = { get "y"() { } };
var c = { get 2() { } };

var e = { set x(v) { } };
var f = { set "y"(v) { } };
var g = { set 2(v) { } };

SpiderMonkey has historically parsed literal accessors using a slightly-tweaked version of its function parsing code. Therefore, as previously explained SpiderMonkey would accept essentially anything which could follow function in a function expression as valid accessor syntax in object literals.

ES5 requires accessors have exact numbers of arguments

A consequence of parsing accessors using generalized function parsing is that SpiderMonkey accepted some nonsensicalities, such as no-argument setters or multiple-argument getters or setters:

var o1 = { get p(a, b, c, d, e, f, g) { /* why have any arguments? */ } };
var o2 = { set p() { /* to what value? */ } };
var o3 = { set p(a, b, c) { /* why more than one? */ } };

ES5 accessor syntax sensibly deems such constructs errors: a conforming ES5 implementation would reject all of the above statements.

SpiderMonkey is changing to follow ES5: getters require no arguments, setters require one argument

SpiderMonkey has now been changed to follow ES5. There seemed little to no gain in continuing to support bizarre numbers of arguments when the spec counseled otherwise, and any code which does end up broken is easily fixed.

As always, you can experiment with a version of Firefox with these changes to accessor syntax by downloading a nightly from nightly.mozilla.org. (Don’t forget to use the profile manager if you want to keep the settings you use with your primary Firefox installation pristine.)


Dear Automobile magazine

I suppose I should appreciate inexplicably being entered in your subscriber database since the May 2010 issue.

I suppose I should appreciate being sent glossy pages full of pictures of beautiful new cars. I do enjoy slick cars, after all (although to be honest, I’d take a classic car any day over something new). (Still, I much prefer to see the physical versions over mere pictures.)

But that doesn’t change the fact that I am perhaps the least likely person to ever succumb to the temptations posed most directly by the cars in your pages, or the accessories of all sorts advertised amongst them. I am a complete losing proposition for you: I don’t pay for your magazine, and I won’t pay your advertisers for it, either.

Maybe you think, because I’m in the 18-24 male demographic, the products in your pages will entice me. I think you will find few people so anomalous as me in that population. I don’t own a car (I bike), I rarely need a car (and on those occasions, borrowing or renting is significantly cheaper), and I don’t plan to own a car in the foreseeable future. And, for as long as I live in the Bay Area, that’s very unlikely to change.

I do appreciate your willingness to send me something for nothing. My office appreciates this, too. (Or at least it appreciates it no less than I do.)

But a friendly suggestion: if you really want to give someone a free subscription to your magazine, give it to someone who might actually read it.

(And in the unlikely event that someone decided to give me a subscription [presumably despite knowing just how little I care about cars] and I somehow missed the new-gift-subscription notice, I’m really sorry, but this magazine just isn’t for me: it’s complete deadweight loss. How about in the future we go do something fun together, mutually agreed upon, instead?)



Senate Joint Resolution 26, the Clean Air Act, and the consequences of inaction


Approximately three months ago I received this (presumably form-generated) email through a mailing list:

Our new senator, Scott Brown, is considering a resolution from Alaskan Sen. Lisa Murkowski — but written by a coal lobbyist — that would roll back Clean Air Act protections.

Sign the petition telling Sen. Brown that the people of Massachusetts support a strong Clean Air Act.

Check out this page at the Environment Massachusetts Web site:


I wrote a brief reply to the list and sender explaining the situation wasn’t as simple as claimed, responded to a short followup question, and called it a wrap. Reactions suggested that the information I communicated was new to many members of the list (all informed and intelligent people, I should note), and it occurred to me that my response might be worth publishing here. However, the resolution appeared dead on arrival, the quixotic creation of a minority senator. Editing and republishing didn’t seem worth the time, until now: S.J.Res. 26 is headed for a Senate floor vote tomorrow. To better inform readers of the full situation, I’ve taken my response, adjusted it for a broader audience, and included it here; I hope you find it informative.

Regulating greenhouse gases using the current Clean Air Act is a dangerous idea

(For readers seeing this via p.m.o: the planet software appears to strip a crucial part of the header for this section. The heading which should be displayed is “Regulating greenhouse gases using the current Clean Air Act is a dangerous idea”, not “Regulating greenhouse gases is a dangerous idea”.)

Regulating greenhouse gases under the current laws is a seductive idea with a large problem. Using current law is politically painless for Congress, avoids legislative delay, and tackles a pressing problem. The dilemma is that tackling greenhouse gases requires a scalpel, but current law provides only a hatchet. The Clean Air Act (link goes to the Act as amended through the 108th Congress) was quite patently never intended to regulate carbon dioxide, and it is wholly unsuited to the task.

The Clean Air Act’s pollution limits are nonsensical applied to greenhouse gases. Title I, Part A, §112(b) lists the initial set of hazardous air pollutants regulated by the Act. It does not contain carbon dioxide, methane, or the various other major greenhouse gases. The Act permits the EPA administrator to revise the list, but he should not do so lightly: certain consequences immediately follow per the Act’s text. The Act mandates a certain level of regulation of “major emitting facilities” of listed pollutants. What’s a “major emitting facility”? According to §169(1), it’s “any of the following [list of various industrial facilities] which emit, or have the potential to emit, one hundred tons per year” of listed air pollutants. Further, “Such term also includes any other source with the potential to emit two hundred and fifty tons per year or more of any air pollutant.” How do these limits compare in the extent of their effect to the original pollutants, and sources, conceived of by the Clean Air Act? My understanding (full disclosure: I can’t find my original source for this sentence) is that past regulation for historically-listed pollutants affected a few hundred energy-generation plants; these days it affects several thousand. But for carbon dioxide, a 100- or 250-ton limit is almost nothing.

The EPA estimates in a tailoring proposal concerning the Clean Air Act and greenhouse gases that applying the 100- and 250-ton limits with respect to GHGs would require the EPA to issue 140 times as many PSD permits as it does now. The requisite man-hours would be 250 times the man-hours spent issuing permits now. The EPA currently issues 280 PSD permits each year; a 140-fold increase would require many large office builds, larger churches, tens of thousands of farms, and many other entities to get permits.

It’s difficult to say the Clean Air Act was intended for this purpose, given the incredible disproportion between limits suitable for GHGs and limits set by the Act. The Clean Air Act concerned toxic chemicals and industrial pollution present in (relatively) small quantities, as the textual limits specifically indicate, not chemicals as abundant as carbon dioxide. Moreover, was the Clean Air Act designed for pervasive, non-localized pollutants like carbon dioxide? It seems unlikely, because regulation explicitly addressed “regions”, not the entire nation.

But the 140-fold increase applies only if you respect the law’s plain text. If you ignore the text and suppose 250 doesn’t mean 250, you can alleviate the problem to a degree. That’s what the EPA proposes in the aforementioned tailoring proposal. Instead of interpreting 100 tons to mean 100 tons, or 250 tons to mean 250 tons, the EPA proposes to interpret each as 10000 tons and 25000 tons, respectively.

The misinterpretation of pollutant limits by a factor of a hundred scales back impact considerably, but it is grossly out of alignment with the plain text of the Act. What if, say, Environment Massachusetts brings a lawsuit to correct this atextual interpretation? (Not all environmental groups are happy about this administrative sleight of hand.) The EPA’s argument is that the language of the Act shows this to be a plausible alteration. It’s certainly true that that might accord with the law’s original intent (although it’s difficult to speak of the intent of hundreds of congressmen from across the country). Nevertheless, are we governed by the divined intentions behind a law, or are we governed by the law’s plain text? Laws don’t say what we think they should have said, they say what they say; 100 and 250 ton limits rather than orders of magnitude larger was certainly no scrivener’s error.

The clear conclusion motivated by this conflict between statutory text and practical effect is that the Clean Air Act was never written to apply to pollutants such as carbon dioxide normally present in amounts far exceeding statutory limits. Thus, the Clean Air Act shouldn’t be read to cover GHGs.

But then you reach a problem: in Massachusetts v. EPA, 549 U. S. 497 (2007), the Supreme Court essentially held that the EPA was required to add GHGs to their list of pollutants. The EPA is therefore required to regulate greenhouse gases according to the Clean Air Act as it stands now. They have no choice in the matter, and their hands are tied in just how carefully, delicately, precisely, etc. they can regulate by the Act itself: in essence they must regulate as if new polluters were large industrial plants such as the Clean Air Act originally targeted.

Senator Murkowski’s resolution would lift the requirement that the EPA regulate greenhouse gases using laws not carefully designed to do so. Rather than dealing with a problem through a means wholly unsuited to it, Congress would remove this power and requirement to use it from the EPA (and only with respect to greenhouse gases — all other existing regulation would remain untouched), to then later replace it with legislation specifically tailored to the goal of combating GHGs.


The laws available to the EPA in pursuing regulation of GHGs are entirely unsuited to the purpose, requiring heavy-handed regulation of two orders of magnitude more entities than these laws have ever addressed before. A deliberate misreading of the Clean Air Act curtails the required regulation’s breadth, but that misreading is subject to challenge in courts. If that misreading is corrected, as it should be, we are in for a world of pain: permits cost hundreds of thousands of dollars and consume a few hundred man-hours of regulatory agency time — each. The EPA will be completely swamped if the Clean Air Act is applied, under Massachusetts v. EPA, according to the Act’s text.

The right thing to do to regulate greenhouse gases is to construct a regulatory regime specifically designed for them, and to strip authority over that problem from the Clean Air Act.

« NewerOlder »