Why do Haskell numerical literals need to start and end with digits?

前端 未结 4 1084
误落风尘
误落风尘 2020-12-21 09:54

In The Haskell 98 Report it\'s said that

A floating literal must contain digits both before and after the decimal point; this ensures that a decimal p

4条回答
  •  情歌与酒
    2020-12-21 10:22

    While it could probably be disambiguated, I don't think there is much to be gained from allowing .7 and 7.. Code is meant to be read by people as well as machines, and it's much easier to accidentally miss a decimal point at either end of a literal than in the middle.

    I'll take the extra readability over the saved byte any day.

提交回复
热议问题