Number literals (Was: Re: Case Range Statement ..)

Don nospam at nospam.com
Wed Jul 8 04:41:35 PDT 2009


Walter Bright wrote:
> Don wrote:
>> Make a leading 0 illegal,
> 
> I'm not sure what benefit that accomplishes.

It catches occasional mistakes such as:
int [] foo = [
   001
   010
   100
];

which are admittedly very rare, though it actually happened to me 
earlier this year. It's quite baffling when it happens -- took me ages 
to track down. It's pretty similar to the way you made 'l' illegal as a 
integer suffix.

int x = 0011l;

Looks like x==111, but in C, x is 9!



More information about the Digitalmars-d mailing list