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

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


Maybe -- the precedent from Python and Ruby for 0o377 is strong than 
Smalltalk precedent at this point.

What's more, you seem to want a generalization to any radix, as if all 
radixes are useful or even used. JS already has 0x for hex, which is 
much more useful than octal. After octal would come binary, and 
CoffeeScript, Python and Ruby precedents want 0b111. After that, there 
really aren't any commonly-used (or all that useful, apart from 
obfuscation exercises) radixes.

So we have a 0x precedent in JS, from C (by way of Java). We have 
nearby/upstream scripting language precedents with Python, Ruby, and 
CoffeeScript, for 0o and 0b. We have zero practical use-cases for 
arbitrary radixes. Furthermore we won't see people migrate from 0x to 
16r, ever.

So all of this says to me we should avoid generalizing for its own sake, 
and follow nearby precedents first.

/be

> Herby Vojčík <mailto:herby at mailbox.sk>
> January 12, 2012 10:48 AM
> Would it be hard to bring in Smalltalkish 8r377? Another (and similar 
> to 0)
> special char for specific radix - well, wouldn’t it be better to 
> include a
> letter for all radixes (CoffeeScript can maybe take it on, too).
>
> Herby
>
> -----Pôvodná správa----- From: Brendan Eich
> Sent: Thursday, January 12, 2012 7:21 PM
> To: Axel Rauschmayer
> Cc: es-discuss
> Subject: Re: Octal literals have their uses (you Unix haters skip this 
> one)
>
> Sorry, are you seriously proposing that Node.js users when they 
> specify file
> permissions should manually write that out? Come on! Sorry, that's 
> just way
> too verbose and ugly.
>
> And performance can be an issue, but the readability and writability
> problems are enough.
>
> /be
>
>
>
> Axel Rauschmayer
> January 12, 2012 10:10 AM
> parseInt("377", 8)? Assuming that performance isn’t an issue.
>
>
>
>
>
>
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
> Brendan Eich <mailto:brendan at mozilla.com>
> January 12, 2012 10:21 AM
> Sorry, are you seriously proposing that Node.js users when they 
> specify file permissions should manually write that out? Come on! 
> Sorry, that's just way too verbose and ugly.
>
> And performance can be an issue, but the readability and writability 
> problems are enough.
>
> /be
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
> Axel Rauschmayer <mailto:axel at rauschma.de>
> January 12, 2012 10:10 AM
> parseInt("377", 8)? Assuming that performance isn’t an issue.
>
>
> Brendan Eich <mailto:brendan at mozilla.com>
> January 12, 2012 10:01 AM
> See https://github.com/jashkenas/coffee-script/pull/2021 -- strict 
> mode support in CoffeeScript exposes a valid use-case, Unix-flavor 
> file permissions (mode bits we used to say). Node.js APIs really want 
> users to call with literals such as 0644. Strict mode says no way.
>
> For now CoffeeScript probably will support 0o644 and translate to hex 
> or decimal literals to dodge the strict error. But ES5 still has octal 
> in Annex B, and AFAIK octal support is still required for web 
> compatibility.
>
> Strict mode is not being adopted widely enough, certainly not in 
> node.js code, to kill octal literals. Killing octal literals is 
> user-hostile when it comes to Unix permissions. So I think we should 
> stop tilting at a friendly windmill, and either support octal literals 
> (but not noctal -- no 08 or 09), or support 0o377 etc. as CoffeeScript 
> looks like it will do.
>
> Some may object to lowercase o as prefix. It's clear enough in all 
> fonts, but if we allow uppercase O too, then some might fear user 
> confusion with 0 used instead of O. But if we support 0o377 and 0O377, 
> we can continue to reject (in strict mode and therefore in Harmony) 
> 00377. Anyway, there's no homograph phishing attack threat as with URLs.
>
> If the CoffeeScript experiment with 0o prefixes for octal works out, I 
> think we should adopt that prefix. But at this point I wouldn't be 
> surprised to see retention of 0377 support be demanded by 
> CoffeeScript/Node.js users, and they have a point.
>
> CoffeeScript can certainly compile this to a strict hex or decimal 
> literal to dodge the error, but then JS/Node.js is at a loss, and for 
> no good reason. In this case I will argue for supporting octal 
> literals in strict mode.
>
> /be
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120112/c6119340/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: postbox-contact.jpg
Type: image/jpeg
Size: 1080 bytes
Desc: not available
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120112/c6119340/attachment-0003.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: postbox-contact.jpg
Type: image/jpeg
Size: 1290 bytes
Desc: not available
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120112/c6119340/attachment-0004.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: postbox-contact.jpg
Type: image/jpeg
Size: 1222 bytes
Desc: not available
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120112/c6119340/attachment-0005.jpg>


More information about the es-discuss mailing list