Nick Sabalausky wrote:
"Andrei Alexandrescu" <seewebsiteforem...@erdani.org> wrote in message news:gutd12$16h...@digitalmars.com...
Let me make a separate point. With "...", people just defined the space operator. What's the space operator? Changes the meaning of 0...10 in two distinct ways:

0...10 is an all-inclusive integer range from 0 to 10
0. ..10 is a right-open floating-point range from 0 to 10
0.. .10 is a right-open floating-point range from 0 to 0.1

So '1.' and '.1' are legal numbers in D? I would have assumed that any numerical literal with a decimal point would require at least one digit on both sides of the decimal point. Not sure I see a good reason for this not to be required.

Agreed. Saving ink in 1. versus 1.0 and .1 versus 0.1 is stupid -- even if we don't consider "the new space operator" implications!!!!!! It really makes it hard to spot the odd decimal value when you're not expecting it there.

That's mainly an American invention. In Europe, in most countries, you couldn't ever write .1 without everybody shouting typo!

Had D been invented in Europe, .1 would never have crossed anybodys mind. After several decades, I'm still uncomfortable when anybody writes .1, be it in programming or on street billboards.


Then we could go on (not that Andrei ever meant it, so I'm not serious here), and write

1.0..2.0   an all-inclusive floating range from 1.0 to 2.0
1.0 ..2.0   a right-inclusive floating range from 1.0 to 2.0
1.0.. 2.0   a left-inclusive floating range from 1.0 to 2.0
1.0 .. 2.0   a non-inclusive floating range from 1.0 to 2.0

1..2   an all-inclusive integer range from 1 to 2
1 ..2   a right-inclusive integer range from 1 to 2
1.. 2   a left-inclusive integer range from 1 to 2
1 .. 2   a non-iclusive integer range from 1 to 2

(And we didn't even need the triple-dot operator!)

But this would break existing code, make white-space significant, choke Andrei, pop Walter's ulcer, and generally be reminiscent of interpreted languages (read: embarrassing).

(Not that whitespace isn't already significant in a way, otherwise we could write 1 . 2 and it would be the same thing as 1.2.)


Actually, I'm not sure there would be ambuguity with the American decimals, either:

1....2   an all-inclusive range from 1. to .2
1. ...2   a right-inclusive range from 1. to .2
1... .2   a left-inclusive range from 1. to .2
1. .. .2   a non-inclusive range from 1. to .2
1...2   Error: improperly mixing integers and floating point.

Note, I'm personally against having decimals in ranges in the first place.

Reply via email to