bearophile Wrote:

> 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
> 

As I slowly approach release of a D version of the General Decimal Arithmetic 
specification:

I agree that this syntax (1. or .1) should not be permitted, but it is called 
out in the GDA specification.

I don't have any problem with not including it. It only arises in converting 
from a string to a decimal number, i.e. Decimal(".1"), Decimal("1.").

Conversion from real numbers or integers is based on what the compiler accepts, 
so Decimal(1_000_000) is accepted even though it isn't allowed in the GDA 
specification. There's really no way to force the compiler not to allow it.

This is just a heads up. I'll modify the code to disallow 1. and .1 strings. If 
anyone has an objection let me know.

It's a relatively small change for me to make, much simpler than a change to 
the compiler.

Paul

Reply via email to