Complete floating point literals

bearophile bearophileHUGS at lycos.com
Sat Jul 9 12:13:06 PDT 2011


This comes from a small sub-thread in D.learn (but I have asked for it the first time in bug 3837 time ago):
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=28030

I suggest to turn floating point literals like the following into syntax errors (maybe just deprecated, so they get accepted using the -d compiler switch), because the saving of one digit is not worth the small troubles they cause now and then:

.5
3.

And require to write them like this:

0.5
3.0

The enhancement request:
http://d.puremagic.com/issues/show_bug.cgi?id=6277

(Daniel Murphy suggests to allow 1.f and 1.L (and maybe .2f and .2L too) but I think this is a special case).

(I think disallowing 3. is also useful if you want to allow the introduction of the .. or ... interval syntax. The trailing FP dot causes some troubles and asks for an extra space).

What do you think?

If I see enough people against this idea I will probably close the enhancement request.

Bye,
bearophile


More information about the Digitalmars-d mailing list