0nnn octal notation considered harmful
bearophile
bearophileHUGS at lycos.com
Fri Feb 11 12:34:54 PST 2011
spir:
> 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.
The 0nnn octal syntax is bug-prone, and not explicit, it's out of place in a language like D that's designed to be a bit safer than C.
The 0onnn syntax adopted by Python3 is safer, more explicit, it's good enough. But the leading zero syntax can't be kept in D for backwards C compatibility, so it needs to be just disallowed statically...
Walter likes the C octal syntax as a personal thing. Andrei prefers a syntax like octal!xxxx that's less compact, even more explicit, library-defined, and it has a corner case (when numbers become very large you need a string):
http://www.digitalmars.com/d/2.0/phobos/std_conv.html#octal
Bye,
bearophile
More information about the Digitalmars-d
mailing list