Number literals (Was: Re: Case Range Statement ..)

bearophile bearophileHUGS at lycos.com
Tue Jul 7 18:51:25 PDT 2009


Andrei Alexandrescu:
> I think the question that should be asked is: would anyone complain if
> they were kept? We have bigger rocks to move than that one.

D has small differences, like disallowing 156l (only 156L is allowed). Such small details build up improving the language.

For example I have put a real bug in a Python program of mine because I have written xrange(100000) instead of xrange(1000000). In D I avoid such bug because I always write such numbers as 1_000_000. 
After that bug I now write in Python like this: xrange(1000*1000) (Python has recently added a peephole optimizer, so that multiplication is now not done at run-time, oh marvel), but that way can't be used for other kind of integer literals. I've asked two times to introduce _ in integer literals in Python too, but at the end Hettinger has answered me that it requires too many changes in the C code and the gain is little because most Python programs don't contain many integer literals (D contains them more often). I don't agree with Hettinger.

Disallowing octal syntax and 5.  .5 can be positive :-)

Bye,
bearophile



More information about the Digitalmars-d mailing list