octal literals, was Re: Implicit enum conversions are a stupid PITA

Rainer Deyke rainerd at eldwood.com
Thu Mar 25 22:57:51 PDT 2010


On 3/25/2010 23:40, Walter Bright wrote:
> Rainer Deyke wrote:
>> I don't mind octal literals, but '0177' is a horrible syntax.  *Every*
>> *single* *time* that I used that syntax in C or C++, I really meant to
>> use a decimal.
> 
> I'm curious what tempted you to use a leading 0 in the first place.

Padding to get an array literal to align properly.  Something like this:

int a[3][3] = {
  {001, 002, 003},
  {010, 020, 030},
  {100, 200, 300},
};

I could have used (and should have used, and eventually did use) spaces
instead, but I don't think they look as nice in this instance.


-- 
Rainer Deyke - rainerd at eldwood.com



More information about the Digitalmars-d mailing list