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

Walter Bright newshound1 at digitalmars.com
Wed Jul 8 12:33:50 PDT 2009


Don wrote:
> 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!

I see your point, but I'd like to add that it is rare enough that it has 
never happened to me in 30 years.



More information about the Digitalmars-d mailing list