More octal questions

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


On Wednesday, February 15, 2012 18:52:09 Adam D. Ruppe wrote:
> On Wednesday, 15 February 2012 at 17:48:03 UTC, H. S. Teoh wrote:
> > Yes, I guessed as much. Which brings up a question of what
> > exactly octal deprecation will entail.
> 
> The goal here is to make sure things either do what they
> look like, or don't compile.
> 
> 010 doesn't do what it looks like to a person used to
> decimal; it is a C octal literal for decimal 8.
> 
> So it is deprecated.
> 
> But, making it mean decimal 10 is also a no go, because
> if you're used to C syntax, it won't do what you expect.
> 
> That's why it is an error. It is sure to confuse *somebody*.
> 
> 01, 02, 03, ... 07 though work in both cases, so they
> might still be allowed. (I'm not sure if they are or not).
> 
> But since there's no confusion for decimal people or for
> C people, there's no problem with those small numbers.

Arguably more import is the fact that making 010 mean 10 would be a problem 
for porting code from C/C++. In general, C/C++ is either valid D code with the 
same semantics, or it doesn't compile (though there are a few exceptions - 
e.g. static arrays being value types). Treating 010 as 10 would violate that. 
So, I'd be very surprised if Walter agreed to do that. It'll just permanently 
stay an error like it is now.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list