Is the world coming to an end?

Michel Fortin michel.fortin at michelf.com
Sat Apr 2 16:11:39 PDT 2011


On 2011-04-02 18:27:12 -0400, ulrik.mikaelsson at gmail.com said:

> 011 = 11
> 0b11 = 3
> 0x11 = 17
> 0o11 = 9
> 
> is much more consistent than
> 
> 011 = 11
> 0b11 = 3
> 0x11 = 17
> octal!11 = 9

I too would prefer 0o11 for consistency.

It's funny that D (the language) has binary notation built-in (which C 
doesn't have) but no octal notation anymore (which C has). You now have 
to resort to a library template for that, and it doesn't work for big 
numbers: try assert(octal!1777777777777777777777 == 
0xFFFF_FFFF_FFFF_FFFF). Not that I expect anyone to want to write big 
64-bit numbers in octal, but it makes the new "official" octal notation 
more like a hack.

But it's a good thing that the old error-prone octal notation is 
deprecated. So overall I think the change is positive, I just find the 
replacement a little too hackish.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list