Annoying octal notation

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Fri Aug 28 15:51:08 CEST 2009


On Thu, 27 Aug 2009 10:31:04 -0700, Ethan Furman wrote:

> Steven D'Aprano wrote:
>> A mistake is still a mistake even if it shared with others.
>> 
>> Treating its with a lead zero as octal was a design error when it was
>> first thought up
> 
> [snippage]
> 
> I have to disagree with you on this one.  The computing world was vastly
> different when that design decision was made.  Space was at a premium,
> programmers were not touch-typists, every character had to count, and
> why in the world would somebody who had to use papertape or punch cards
> add a lead zero without a *real* good reason?  I submit that that real
> good reason was to specify an octal literal, and not a decimal literal.

Octal with a leading 0 comes from B, which influenced C, which influenced 
many languages. B was designed in 1969, the same year as Pascal, not the 
1950s -- six years *after* Basic, ten years after Lisp and Cobol, eleven 
years after Algol, and thirteen years after Fortran. *None* of these 
other languages use a leading 0 for Octal, and none of them are 
particularly terse.

Obviously I can't speak for Ken Thompson's motivation in creating this 
feature, but I'm pretty sure it wasn't to save typing or space on 
punchcards. Even in 1969, hex was more common than octal, and yet hex 
values are written with 0x. My guess is that he wanted all numbers to 
start with a digit, to simplify parsing, and beyond that, it was just his 
programming style -- why call the copy command `copy` when you could call 
it `cp`? (Thompson was the co-inventor of Unix.)


-- 
Steven



More information about the Python-list mailing list