Complete floating point literals

Jacob Carlborg doob at me.com
Sun Jul 10 02:29:46 PDT 2011


On 2011-07-09 21:28, Timon Gehr wrote:
> Nick Sabalausky wrote:
>> "bearophile"<bearophileHUGS at lycos.com>  wrote in message
>> news:iva982$dm8$1 at digitalmars.com...
>>> 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.
>>>
>>
>> I see zero benefit to the 1., .1 feature and it's been a problem in syntax
>> discussions in the past. I'm completely in favor of ditching it, and have
>> already put in a bugzilla vote for bearophile's enhancement request.
>
> +1. Another benefit of ditching it is neater UFCS (if it ever gets implemented):
>
> 4.foo(bar);
>
> Cheers,
> -Timon

Agree. 1.f will conflict with UFCS.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list