const formal parameters?

Mark S. Miller erights at
Thu Jun 19 20:17:21 PDT 2008

On Thu, Jun 19, 2008 at 5:39 PM, Brendan Eich <brendan at> wrote:
> On Jun 19, 2008, at 4:07 PM, Mark S. Miller wrote:
>> As previously mentioned, we've decided to allow "const" variable
>> declarations into ES3.1 under the "parses on 3/4 browser rule"
>> (FF,Safari,Opera) since it also aids integrity.
> It may parse, but if const turns into var, as in Opera, or is not
> block-scoped (Firefox and Safari), then no one can count on it until some
> future releases.

[out of order]
> What good is the 3/4 browsers rule if it allows wildly divergent (or in
> Opera's case, mapping const to var, meaningless) semantics for const?
> Getting something to parse, but not behave as proposed (adding integrity),
> seems like a sure way to deliver secure-looking but insecure-behaving code
> to certain browsers.

So long as it parses, that would allow code to version sniff and
adapt, with conditionals, to different execution environments. That's
why we're using the "parses on 3/4 browsers" criterion. (Thanks
Maciej, I think)

> This again makes me ask: what's the plan for getting
> "alpha" implementations of ES3.1 interoperating before the standard is
> pushed through Ecma to ISO?

I don't know if the ES3.1 WG has discussed how to get to ISO. I've
only participated in discussions re an Ecma std, for which we're
planning to leverage the ES4 RI. What would you suggest for ISO?

>> However, it's a bit
>> mysterious how to declare formal parameter variables to be const in a
>> way that'll parse on 3/4 browsers.
> It's not mysterious, it is simply not possible.

I was hoping that the

    function foo(x, y) { const y; return [x, y];}

syntax I suggested was close enough to possible. However, I just
verified that it doesn't parse on Opera 9.5 either, so I give up on
this one.

> I don't know for sure, but it is plausible since we do not require
> initialization in the declaration, rather write-once. But does it matter? I
> think ES3.1 is way over the line of mission creep in trying to get const
> formal parameters wedged in. They do not parse in any browser
> implementations. 'const' forward compatibility is iffy to broken due to the
> different scope rules. It seems to me, and I'm writing this in order to help
> 3.1 get done and done well, that you really should just cut anything like
> const parameters now.

I certainly appreciate the sentiment, and I agree on this case. It
just seems weird to be able to declare local variables const but not
be able to declare parameter variables const. Oh well, it's not the
weirdest thing that we've decided to live with.


More information about the Es4-discuss mailing list