Legacy const, attempt 2 (Re: Legacy const)

# Geoffrey Sneddon (12 years ago)

I've just had it pointed out to me that my original email made little sense, so let's try again:

const has historically been needed in non-strict/strict code for web compatibility on non-IE code (typically either down to server-side UA sniffing or just explicitly non-support of IE). IE still doesn't support it, which may suggest it's not needed for compatibility any more, but as far as I can tell removing it would break enough to make it infeasible.

As such, we should spec it: likely block-scoped in modules, and function-scoped otherwise. We should only really not spec it if we can get everyone who currently supports it to drop it.

# Brendan Eich (12 years ago)

Geoffrey Sneddon wrote:

As such, we should spec it: likely block-scoped in modules, and function-scoped otherwise. We should only really not spec it if we can get everyone who currently supports it to drop it.

The TC39 group met early this year (IIRC it was the Yahoo!-hosted meeting in January) and Gavin B. of Apple agreed to try changing const to match ES6 (block-scoped everywhere), and to reserve 'let' everywhere too.

TC39 is not inclined to maximize compatibility for 'const' given non-support in IE so far, and enough non-interoperation among the other browser implementations to keep web developers from relying on it even in non-IE (if (!document.all)) code forks.

# Oliver Hunt (12 years ago)

On Apr 18, 2012, at 11:32 AM, Brendan Eich <brendan at mozilla.org> wrote:

Geoffrey Sneddon wrote:

As such, we should spec it: likely block-scoped in modules, and function-scoped otherwise. We should only really not spec it if we can get everyone who currently supports it to drop it.

The TC39 group met early this year (IIRC it was the Yahoo!-hosted meeting in January) and Gavin B. of Apple agreed to try changing const to match ES6 (block-scoped everywhere), and to reserve 'let' everywhere too.

Alas reserving let everywhere failed, at least one canadian bank has some (really screwed up) code that has a variable named let. Gavin and I are pondering the difficulty of having let reserved everywhere unless you use it in a non-let syntax.

# gaz Heyes (12 years ago)

On 18 April 2012 19:13, Geoffrey Sneddon <gsneddon at opera.com> wrote:

I've just had it pointed out to me that my original email made little sense, so let's try again:

const has historically been needed in non-strict/strict code for web compatibility on non-IE code (typically either down to server-side UA sniffing or just explicitly non-support of IE). IE still doesn't support it, which may suggest it's not needed for compatibility any more, but as far as I can tell removing it would break enough to make it infeasible.

As such, we should spec it: likely block-scoped in modules, and function-scoped otherwise. We should only really not spec it if we can get everyone who currently supports it to drop it.

IE has consts, use execScript with vbs. I think Andrea did a blog post on it: < webreflection.blogspot.co.uk/2007/10/cow-javascript-define-php-like-function.html

The const keyword is a little freaky overall, Firefox seems to support it yet Opera (last time I checked) supports the keyword but doesn't perform a const operation.

# Brendan Eich (12 years ago)

gaz Heyes wrote:

IE has consts, use execScript with vbs. I think Andrea did a blog post on it: webreflection.blogspot.co.uk/2007/10/cow-javascript-define-php-like-function.html

Any port in a storm, but c'mon -- we're talking about 'const x = 42;' written in JS. That has never been supported in IE and I recall an IE blog post (from Allen, if memory serves) about why not.

# Allen Wirfs-Brock (12 years ago)

On Apr 19, 2012, at 10:58 AM, Brendan Eich wrote:

gaz Heyes wrote:

IE has consts, use execScript with vbs. I think Andrea did a blog post on it: webreflection.blogspot.co.uk/2007/10/cow-javascript-define-php-like-function.html

Any port in a storm, but c'mon -- we're talking about 'const x = 42;' written in JS. That has never been supported in IE and I recall an IE blog post (from Allen, if memory serves) about why not.

blogs.msdn.com/b/ie/archive/2010/08/25/chakra-interoperability-means-more-than-just-standards.aspx

But that was then and the world is different today. I certainly don't know anything about the plans for IE10.