More octal questions

Jonathan M Davis jmdavisProg at gmx.com
Wed Feb 15 16:53:02 PST 2012


On Thursday, February 16, 2012 00:38:10 Stewart Gordon wrote:
> On 15/02/2012 16:41, Jonathan M Davis wrote:
> <snip>
> 
> > They're not left over at all, and they have nothing to do with octal.
> 
> <snip>
> 
> They are something to do with octal: because in D an integer literal
> beginning with 0 is defined to be octal, the compiler must interpret them
> as such if it is going to accept them at all.
> 
> Of course, under current D2 without -d, the compiler rejects zero-led
> integer literals greater than 07. But it's because of this octal legacy
> that it accepts up to 07 but not 08, 09 or 010.

They have nothing to do with octal in that they were not intentionally octal. 
I was merely using the leading 0 without thinking about it, because having 
leading 0s generally makes more sense when dealing with the date/time stuff. 
The fact that they were octal is incidental. They result in the same number 
either way, save for 08 and 09 not working.

> Still, what's the long-term plan? To remove octal literals completely, and
> allow decimal literals to have leading 0s? Or to continue to allow just up
> to 07 until the end of time?

I expect that we will never allow decimal literals with leading 0s which would 
end up with different numbers than they would if we supported octal literals, 
because otherwise any C/C++ code which is ported to D and uses octal literals 
will then compile with different semantics, and that's generally verboten in D 
(there are a few exceptions, but they're quite rare). I'm not aware of Walter 
actually having stated what his longterm plan is though.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list