read-ing scientific notation

Simon Peyton-Jones
Fri, 12 Oct 2001 07:45:59 -0700

| GHC is oddly particular about decimal points in "read"-ing in=20
| of Doubles in scientific notation. It seems that read=20
| "3.0e-06" is acceptable but read "3e-06" is not (both read=20
| "3" and read "3.0" work fine as Doubles). It's the same in=20
| nhc and hugs. Perhaps this is some standard somewhere that=20
| Perl doesn't understand?

It's true about the Haskell language too, and that's why it's true of
Read.  The lexical syntax says that



	10 e3

(i.e. two lexemes).   I don't like this choice, and it could be "fixed"=20
in the Revised H98 report.  The current production for float is

	float  ->  decimal . decimal[(e | E)[- | +]decimal]=20

I guess we could change that to=20

	exponent -> (e|E) [+|-] decimal

	float -> decimal . decimal [exponent]
	         |   decimal exponent

It's an unforced change and therefore to be regarded with
deep suspicion. I'd be interested in people's views about this.