A lexical change (a breaking change, but trivial to fix)

Jonathan M Davis jmdavisProg at gmx.com
Sat Jul 7 18:35:16 PDT 2012


On Sunday, July 08, 2012 03:29:37 deadalnix wrote:
> On 08/07/2012 00:04, H. S. Teoh wrote:
> > On Sat, Jul 07, 2012 at 11:41:43PM +0200, Alex Rønne Petersen wrote:
> >> On 07-07-2012 23:39, Mehrdad wrote:
> >>> This might sound silly, but how about if D stopped allowing 0..2  as a
> >>> range, and instead just said "invalid floating-point number"?
> > 
> > [...]
> > 
> >> ... why is this even done at the lexical stage? It should be done at
> >> the parsing stage if anything.
> > 
> > [...]
> > 
> > This is because the lexer can mistakenly identify it as "0." followed by
> > ".2" instead of "0" followed by ".." followed by "2".
> > 
> > IMAO, this problem is caused by floating point notational stupidities
> > like 0. and .1, especially the former. Get rid of the former (and
> > optionally the latter) will fix a whole bunch of lexer pain in D.
> > 
> > 
> > T
> 
> 0. should be banned because of UFCS anyway.

If you do 0.func(), UFCS works. If you do 0.f(), UFCS works (so 0.f as a 
literal is illegal), but there's notthing about UFCS preventing 0. from 
working as long as there's nothing immediately after it which could be 
considered a function (which would just be any letter and _). So, UFCS really 
isn't an argument for banning 0. as a literal. It's the facts that it's 
ludicrous to accept a partial literal and that it causes parsing problems 
which make it so that it should be banned.

- Jonathan M Davis


More information about the Digitalmars-d mailing list