On 4/2/2011 4:11 PM, Michel Fortin wrote:
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).

The problem with the octal literals is, as has been often complained about, people getting surprised by it. I've never heard of anyone being surprised by the binary or hex literals.

You now have to resort to a
library template for that,

I think it's a feature, not a "resort", that library templates can do this well. I think it's far better than C++0x's user defined literals, for example.

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.

If you use octal!"1777777777777777777777" it will work correctly. You're right in that the decimal literal being "converted" to octal is a bit of a hack.

The octal!1777777777777777777777 will fail at compile time with an integer overflow, it never gets to the runtime assert.

Reply via email to