Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Annoying octal notation

Reply
Thread Tools

Re: Annoying octal notation

 
 
Derek Martin
Guest
Posts: n/a
 
      08-21-2009
John Nagle wrote:
> Yes, and making lead zeros an error as suggested in PEP 3127 is a
> good idea. It will be interesting to see what bugs that flushes
> out.


James Harris wrote:
> It maybe made sense once but this relic of the past should have been
> consigned to the waste bin of history long ago.


Sigh. Nonsense. I use octal notation *every day*, for two extremely
prevalent purposes: file creation umask, and Unix file permissions
(i.e. the chmod() function/command).

I fail to see how 0O012, or even 0o012 is more intelligible than 012.
The latter reads like a typo, and the former is virtually
indistinguishable from 00012, O0012, or many other combinations that
someone might accidentally type (or intentionally type, having to do
this in dozens of other programming languages). I can see how 012 can
be confusing to new programmers, but at least it's legible, and the
great thing about humans is that they can be taught (usually). I for
one think this change is completely misguided. More than flushing out
bugs, it will *cause* them in ubiquity, requiring likely terabytes of
code to be poured over and fixed. Changing decades-old behaviors
common throughout a community for the sake of avoiding a minor
inconvenience of the n00b is DUMB.

--
Derek D. Martin
http://www.pizzashack.org/
GPG Key ID: 0x81CFE75D


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFKjvopdjdlQoHP510RAlw1AJ9Adaa4HfSOIzRNc+cbDj 3hFDmrvgCgiyoa
VvbNINYG2YAsjbtoKO4kPGA=
=q2MS
-----END PGP SIGNATURE-----

 
Reply With Quote
 
 
 
 
Piet van Oostrum
Guest
Posts: n/a
 
      08-21-2009
>>>>> Derek Martin <(E-Mail Removed)> (DM) wrote:

>DM> I fail to see how 0O012, or even 0o012 is more intelligible than 012.
>DM> The latter reads like a typo, and the former is virtually
>DM> indistinguishable from 00012, O0012, or many other combinations that
>DM> someone might accidentally type (or intentionally type, having to do
>DM> this in dozens of other programming languages).


You're right. Either hexadecimal should have been 0h or octal should
have been 0t :=)
--
Piet van Oostrum <(E-Mail Removed)>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
MRAB
Guest
Posts: n/a
 
      08-21-2009
Piet van Oostrum wrote:
>>>>>> Derek Martin <(E-Mail Removed)> (DM) wrote:

>
>> DM> I fail to see how 0O012, or even 0o012 is more intelligible than 012.
>> DM> The latter reads like a typo, and the former is virtually
>> DM> indistinguishable from 00012, O0012, or many other combinations that
>> DM> someone might accidentally type (or intentionally type, having to do
>> DM> this in dozens of other programming languages).

>
> You're right. Either hexadecimal should have been 0h or octal should
> have been 0t :=)


I have seen the use of Q/q instead in order to make it clearer. I still
prefer Smalltalk's 16rFF and 8r377.
 
Reply With Quote
 
James Harris
Guest
Posts: n/a
 
      08-21-2009
On 21 Aug, 20:48, Derek Martin <(E-Mail Removed)> wrote:

....

> James Harris wrote:
> > It maybe made sense once but this relic of the past should have been
> > consigned to the waste bin of history long ago.

>
> Sigh. *Nonsense. *I use octal notation *every day*, for two extremely
> prevalent purposes: file creation umask, and Unix file permissions
> (i.e. the chmod() function/command). *


You misunderstand. I was saying that taking a leading zero as
indicating octal is archaic. Octal itself is fine where appropriate.

The chmod command doesn't require a leading zero.

James
 
Reply With Quote
 
James Harris
Guest
Posts: n/a
 
      08-21-2009
On 21 Aug, 22:18, MRAB <(E-Mail Removed)> wrote:
> Piet van Oostrum wrote:
> >>>>>> Derek Martin <(E-Mail Removed)> (DM) wrote:

>
> >> DM> I fail to see how 0O012, or even 0o012 is more intelligible than 012.
> >> DM> The latter reads like a typo, and the former is virtually
> >> DM> indistinguishable from 00012, O0012, or many other combinations that
> >> DM> someone might accidentally type (or intentionally type, having to do
> >> DM> this in dozens of other programming languages). *

>
> > You're right. Either hexadecimal should have been 0h or octal should
> > have been 0t :=)

>
> I have seen the use of Q/q instead in order to make it clearer. I still
> prefer Smalltalk's 16rFF and 8r377.


Two interesting options. In a project I have on I have also considered
using 0q as indicating octal. I maybe saw it used once somewhere else
but I have no idea where. 0t was a second choice and 0c third choice
(the other letters of oct). 0o should NOT be used for obvious reasons.

So you are saying that Smalltalk has <base in decimal>r<number> where
r is presumably for radix? That's maybe best of all. It preserves the
syntactic requirement of starting a number with a digit and seems to
have greatest flexibility. Not sure how good it looks but it's
certainly not bad.

0xff & 0x0e | 0b1101
16rff & 16r0e | 2r1101

Hmm. Maybe a symbol would be better than a letter.

James
 
Reply With Quote
 
Steven D'Aprano
Guest
Posts: n/a
 
      08-22-2009
On Fri, 21 Aug 2009 14:48:57 -0500, Derek Martin wrote:

>> It maybe made sense once but this relic of the past should have been
>> consigned to the waste bin of history long ago.

>
> Sigh. Nonsense. I use octal notation *every day*, for two extremely
> prevalent purposes: file creation umask, and Unix file permissions (i.e.
> the chmod() function/command).


And you will still be able to, by explicitly using octal notation.


> I fail to see how 0O012, or even 0o012 is more intelligible than 012.


The first is wrong, bad, wicked, and if I catch anyone using it, they
will be soundly slapped with a halibut. *wink*

Using O instead of o for octal is so unreadable that I think it should be
prohibited by the language, no matter that hex notation accepts both x
and X.


> The latter reads like a typo,


*Everything* reads like a typo if you're unaware of the syntax being used.


> and the former is virtually
> indistinguishable from 00012, O0012, or many other combinations that
> someone might accidentally type (or intentionally type, having to do
> this in dozens of other programming languages).


Agreed.


> I can see how 012 can
> be confusing to new programmers, but at least it's legible, and the
> great thing about humans is that they can be taught (usually).


And the great thing is that now you get to teach yourself to stop writing
octal numbers implicitly and be write them explicitly with a leading 0o
instead

It's not just new programmers -- it's any programmer who is unaware of
the notation (possibly derived from C) that a leading 0 means "octal".
That's a strange and bizarre notation to use, because 012 is a perfectly
valid notation for decimal 12, as are 0012, 00012, 000012 and so forth.
Anyone who has learnt any mathematics beyond the age of six will almost
certainly expect 012 to equal 12. Having 012 equal 10 comes as a surprise
even to people who are familiar with octal.


> I for
> one think this change is completely misguided. More than flushing out
> bugs, it will *cause* them in ubiquity, requiring likely terabytes of
> code to be poured over and fixed. Changing decades-old behaviors common
> throughout a community for the sake of avoiding a minor inconvenience of
> the n00b is DUMB.


Use of octal isn't common. You've given two cases were octal notation is
useful, but for every coder who frequently writes umasks on Unix systems,
there are a thousand who don't.

It's no hardship to write 0o12 instead of 012.


--
Steven
 
Reply With Quote
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      08-22-2009
On Fri, 21 Aug 2009 16:52:29 -0700 (PDT), James Harris
<(E-Mail Removed)> declaimed the following in
gmane.comp.python.general:

> So you are saying that Smalltalk has <base in decimal>r<number> where
> r is presumably for radix? That's maybe best of all. It preserves the
> syntactic requirement of starting a number with a digit and seems to
> have greatest flexibility. Not sure how good it looks but it's
> certainly not bad.
>
> 0xff & 0x0e | 0b1101
> 16rff & 16r0e | 2r1101
>
> Hmm. Maybe a symbol would be better than a letter.
>

Or Ada's 16#FF#, 8#377#...

I forget if DEC/VMS FORTRAN or Xerox Sigma FORTRAN used x'FF' or
'FF'x, and o'377' or '377'o
--
Wulfraed Dennis Lee Bieber KD6MOG
(E-Mail Removed) HTTP://wlfraed.home.netcom.com/

 
Reply With Quote
 
MRAB
Guest
Posts: n/a
 
      08-22-2009
Dennis Lee Bieber wrote:
> On Fri, 21 Aug 2009 16:52:29 -0700 (PDT), James Harris
> <(E-Mail Removed)> declaimed the following in
> gmane.comp.python.general:
>
>> So you are saying that Smalltalk has <base in decimal>r<number> where
>> r is presumably for radix? That's maybe best of all. It preserves the
>> syntactic requirement of starting a number with a digit and seems to
>> have greatest flexibility. Not sure how good it looks but it's
>> certainly not bad.
>>
>> 0xff & 0x0e | 0b1101
>> 16rff & 16r0e | 2r1101
>>
>> Hmm. Maybe a symbol would be better than a letter.
>>

> Or Ada's 16#FF#, 8#377#...
>

'#' starts a comment, so that's right out!

> I forget if DEC/VMS FORTRAN or Xerox Sigma FORTRAN used x'FF' or
> 'FF'x, and o'377' or '377'o


 
Reply With Quote
 
MRAB
Guest
Posts: n/a
 
      08-22-2009
David wrote:
> Il Fri, 21 Aug 2009 16:52:29 -0700 (PDT), James Harris ha scritto:
>
>
>> 0xff & 0x0e | 0b1101
>> 16rff & 16r0e | 2r1101
>>
>> Hmm. Maybe a symbol would be better than a letter.

>
> What about 2_1011, 8_7621, 16_c26h or 2;1011, 8;7621, 16;c26h ?
>

'_': what if in the future we want to allow them in numbers for clarity?

';': used to separate multiple statements on a line (but not used that
often).
 
Reply With Quote
 
Derek Martin
Guest
Posts: n/a
 
      08-22-2009
On Sat, Aug 22, 2009 at 10:03:35AM +1000, Ben Finney wrote:
> > and the former is virtually indistinguishable from 00012, O0012, or
> > many other combinations that someone might accidentally type (or
> > intentionally type, having to do this in dozens of other programming
> > languages).

>
> Only if you type the letter in uppercase. The lower-case ‘o’ is much
> easier to distinguish.


It is easier, but I dispute that it is much easier.

> Whether or not you find ‘0o012’ easily distinguishable as a non-decimal
> notation, it's undoubtedly easier to distinguish than ‘012’.


012 has meant decimal 10 in octal to me for so long, from its use in
MANY other programming languages, that I disagree completely.

> > I can see how 012 can be confusing to new programmers, but at least
> > it's legible, and the great thing about humans is that they can be
> > taught (usually). I for one think this change is completely misguided.

>
> These human programmers, whether newbies or long-experienced, also deal
> with decimal numbers every day, many of which are presented as a
> sequence of digits with leading zeros — and we continue to think of them
> as decimal numbers regardless. Having the language syntax opposed to
> that is


...consistent with virtually every other popular programming language.

--
Derek D. Martin
http://www.pizzashack.org/
GPG Key ID: 0x81CFE75D


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFKkEExdjdlQoHP510RAr6tAJ9Ik6uKD0i1h04LNR9ZaH gFLwO9RQCfe+kx
jvvtN0HScEgH3wO+6WBPeAQ=
=tnaa
-----END PGP SIGNATURE-----

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to convert Infix notation to postfix notation Tameem C Programming 454 01-31-2014 06:01 PM
Re: Annoying octal notation Simon Forman Python 4 09-03-2009 01:43 PM
Re: Annoying octal notation James Harris Python 1 08-23-2009 06:11 PM
Hungarian Notation Vs. Pascal Notation? Grey Squirrel ASP .Net 6 03-21-2007 09:42 AM
reg exp and octal notation Lucas Branca Python 5 03-05-2004 04:33 PM



Advertisments