Implicit enum conversions are a stupid PITA

Adam D. Ruppe destructionator at gmail.com
Thu Mar 25 12:33:50 PDT 2010


On Thu, Mar 25, 2010 at 03:05:28PM -0400, bearophile wrote:
> The answer is essentially: how can you represent very large 64 bit octal values with that syntax?

Have the user switch over to the string notation in those rare cases.

The argument most often brought up for keeping octal *at all* is unix
filesystem permissions. They are only ever as big as four digits (AFAIK).

7777 certainly fits in an integer. Even 8 digits: 77_777_777 is still well
within the limits of an integer literal.


So, in theory, yeah, the integer can't express all numbers in octal that
can fit. But in practice? How often would this come up? Does the language
*really* need to address this globally just to avoid the quotes in those
specific situations?

The one person who has such a use for giant octal literals might complain
"gah I have to quote it once it gets to a certain size, this kinda sucks",
but I'm ok with that.



Another possibility might be having integer literals actually be infinite
in size in the compiler, and use a template alias.. or something, to take
them unmolested into CTFE for manipulation.

This would also be useful for bignum structs. You can just reuse the plain
old integer literal when initalizing them.

Then, if the literal is too big to fit in the type requested, the compiler
throws an error only at the last minute it can possibly check.


This would be more generally useful than a special octal literal, but since
it means changes to the compiler, the cost is higher too. The nice thing
about my O!100 or Andrei's octal!"100" is that they work in D today.

-- 
Adam D. Ruppe
http://arsdnet.net



More information about the Digitalmars-d mailing list