More octal questions

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Feb 15 10:21:18 PST 2012


On Wed, Feb 15, 2012 at 06:52:09PM +0100, Adam D. Ruppe wrote:
[...]
> 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*.

True. Especially if a C coder tries calling chmod() with 0644 and it
silently gets interpreted as decimal.


> 01, 02, 03, ... 07 though work in both cases, so they
> might still be allowed. (I'm not sure if they are or not).
[...]

Currently the compiler accepts them (even without -deprecated).
Otherwise std.datetime wouldn't compile. :)


T

-- 
Bomb technician: If I'm running, try to keep up.


More information about the Digitalmars-d-learn mailing list