Octal literals have their uses (you Unix haters skip this one)

Brendan Eich brendan at mozilla.com
Thu Jan 12 12:30:30 PST 2012

> Greg Smith <mailto:greg at bocoup.com>
> January 12, 2012 12:08 PM
> To me this seems like an exception rather than a common problem. Most 
> APIs / tools don't use octals for this type of thing. Seems 
> unnecessary to add to the language for this one use case.

"Add to the language" is not accurate. Octal is *already* supported by 
JS engines today, and again, AFAIK, it is required for web 
compatibility. Banishing octal to the non-normative Annex B, banning it 
from strict mode -- that does not remove octal from JS in reality.

Given this, the shoe is rather on the other foot: strict-mode has one 
more drawback from the point of view of a non-trivial cohort of users 
(Node.js hackers who wrangle Unix permissions).
> Not a Linux hater by any means, just the parseInt thing doesn't bother 
> me for this one situation.

That's nice, but Node.js supports JS non-strict and people use it 
freely, including not quoting octal literals (the API works with string 
inputs too, so explicit parseInt is not required).

The problem for CoffeeScript users can be solved quickly via 0o 
prefixing. The problem for JS users is also easy: don't use strict mode. 
Is this really what we want? What good have we done by banning octal in 
strict mode?

> Or am I wrong and there are other common uses for octal literals?

The only use case I'm citing here is Unix permission modes. That's enough.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120112/92b754b9/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: postbox-contact.jpg
Type: image/jpeg
Size: 1212 bytes
Desc: not available
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120112/92b754b9/attachment.jpg>

More information about the es-discuss mailing list