www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - \ OctalDigit etc.

reply Moritz Warning <moritzwarning _nospam_web.de> writes:
This was probably discussed before.
But I run into a problem when I was checking
for missing characters in a long string sequence since some application 
kept telling me that it was invalid.

The point was that \012 is not '\0' '1' '2' but one char '\012'.
other representations with hexadecimal numbers have an
alphabetical char to indicate smth. special might follow (\xaa).

In my case thinking of \0 being the same as single char and in a string
was wrong.
This is inconsistent and I think many could get wrong as I did.

I don't have much hope to get a convenient solution as for hexadecimal 
representations.
But I thought I just post this for others who stumble over the same 
stone. :/
Mar 15 2008
parent reply Walter Bright <newshound1 digitalmars.com> writes:
The way the octal escape sequences work is pretty standard practice. To 
change it would be to confuse the other half of people who use it :-(
Mar 19 2008
next sibling parent reply Sean Kelly <sean invisibleduck.org> writes:
== Quote from Walter Bright (newshound1 digitalmars.com)'s article
 The way the octal escape sequences work is pretty standard practice. To
 change it would be to confuse the other half of people who use it :-(

The format of octal literals is one of the more harebrained ideas we've inherited from C. I'd love to require an "0o" prefix or something of the sort, but it would cause unnecessary trouble for ported C code. Ah well. Sean
Mar 19 2008
parent bearophile <bearophileHUGS lycos.com> writes:
Sean Kelly:
 The format of octal literals is one of the more harebrained ideas we've
inherited from C.  I'd love to require
 an "0o" prefix or something of the sort, but it would cause unnecessary
trouble for ported C code.  Ah well.

Just fixed in Python 3.0 ;-) Among many other things. But I too can see the situation is different: you usually don't port much code from C to Python. Bye, bearophile
Mar 20 2008
prev sibling parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Walter Bright" <newshound1 digitalmars.com> wrote in message 
news:frs9ov$2258$1 digitalmars.com...
 The way the octal escape sequences work is pretty standard practice. To 
 change it would be to confuse the other half of people who use it :-(

People use them?
Mar 20 2008
parent BCS <BCS pathlink.com> writes:
Jarrett Billingsley wrote:
 "Walter Bright" <newshound1 digitalmars.com> wrote in message 
 news:frs9ov$2258$1 digitalmars.com...
 
The way the octal escape sequences work is pretty standard practice. To 
change it would be to confuse the other half of people who use it :-(

People use them?

People is simply plural. Therefor, if there are 2 people who use them, then the statement is correct (but not particularly useful). As to if /enough/ people use them to be worth anything... Also, I expect you (and most anyone) use them regularly because \0 is actual a 1 char octal escape sequence. That still has little bearing on the topic though.
Mar 20 2008