0nnn octal notation considered harmful

spir denis.spir at gmail.com
Fri Feb 11 15:20:00 PST 2011


On 02/11/2011 10:54 PM, Nick Sabalausky wrote:
> "spir"<denis.spir at gmail.com>  wrote in message
> news:mailman.1504.1297453559.4748.digitalmars-d at puremagic.com...
>> Hello,
>>
>> Just had a strange bug --in a test func!-- caused by this notation. This
>> is due in my case to the practice (common, I guess) of "pretty printing"
>> int numbers using %0nd or %0ns format, to get a nice alignment. Then, if
>> one feeds back results into D code, they are interpreted as octal...
>> Now, i know it: will pad with spaces instead ;-)
>>
>> Copying a string'ed integer is indeed not the only this notation is
>> bug-prone: prefixing a number with '0' should not change its value (!).
>> Several programming languages switched to another notation; like 0onnn,
>> which is consistent with common hex&  bin notations and cannot lead to
>> misinterpretation. Such a change would be, I guess, backward compatible;
>> and would not be misleading for C coders.
>>
>
> Yea, octal!"nnn" has already made the exceedingly rare uses of octal
> literals completely obsolete *long* ago. I know I for one am getting really
> tired of this completely unnecessary landmine in the language continuing to
> exist. The heck with std.xml, if anything, *this* needs nuked. If silently
> changed behavior is a problem, then just make it an error. Done. Minefield
> cleared.

Thanks you (and Bearohile, IIRC) for the tip about octal!"nnn". Useless for me, 
unfortunately, since my problem (as you suggest) is not with how to write them, 
but the sheer existence of this $%*£µ#! notation ;-) What we need is a time 
bomb sent to ~ 1973.

Denis
-- 
_________________
vita es estrany
spir.wikidot.com



More information about the Digitalmars-d mailing list