Octal Literals

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Tue Jul 17 15:35:36 PDT 2012


On Tue, 17 Jul 2012 23:53:47 +0200
"Dave X." <dxuhuang at gmail.com> wrote:

> I'm a fresh college graduate who just got a job as a software 
> developer, and I have been enthusiastically watching D for a 
> while now (I program primarily in Java and C). I have some 
> functional programming experience in Haskell and Scala as well.
> 

I wish D had been as far along as it is now back when I was in college!

> I like using octal numbers, and I've always been interested in 
> D's octal literals. I'm glad to see that the traditional syntax 
> of C's octal literals is being replaced by a more readable one. 
> However, I can't help but think that the template solution 
> ("octal!nnn") is a little too roundabout; is there a reason that 
> that the "0o" prefix, which is already well established in 
> languages like Haskell, OCaml, and Python, is not used?

It was suggested a few times, but there was a lot of bikeshedding over
it. Some people liked it, some hated it. One of the bigger objections was that octal literals were too rarely-needed to justify adding a
new syntax into the language (this was at a time when D was far enough
along that we were trying to start stabalizing the langauge rather
than tossing in more stuff). The bikeshedding went around and around
like that for awhile, during which time the awful old 0123 octal syntax
remained.

So when it was discovered that D's templates made it possible to
implement octal literals in the library (octal!123), instead of in the
language itself (0o123), that solved the deadlock and we went with it.



More information about the Digitalmars-d mailing list